hytopia 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/boilerplate/assets/map.json +191 -43
  2. package/docs/server.playercameramode.md +14 -0
  3. package/examples/hygrounds/README.md +0 -0
  4. package/examples/hygrounds/assets/audio/sfx/chest-open-1.mp3 +0 -0
  5. package/examples/hygrounds/assets/audio/sfx/chest-open-2.mp3 +0 -0
  6. package/examples/hygrounds/assets/audio/sfx/machine-gun-reload.mp3 +0 -0
  7. package/examples/hygrounds/assets/audio/sfx/machine-gun-shoot.mp3 +0 -0
  8. package/examples/hygrounds/assets/audio/sfx/medpack-consume.mp3 +0 -0
  9. package/examples/hygrounds/assets/audio/sfx/mining-drill-drilling.mp3 +0 -0
  10. package/examples/hygrounds/assets/audio/sfx/pistol-reload.mp3 +0 -0
  11. package/examples/hygrounds/assets/audio/sfx/pistol-shoot.mp3 +0 -0
  12. package/examples/hygrounds/assets/audio/sfx/player-hurt.mp3 +0 -0
  13. package/examples/hygrounds/assets/audio/sfx/rifle-reload.mp3 +0 -0
  14. package/examples/hygrounds/assets/audio/sfx/rifle-shoot.mp3 +0 -0
  15. package/examples/hygrounds/assets/audio/sfx/rocket-launcher-explosion.mp3 +0 -0
  16. package/examples/hygrounds/assets/audio/sfx/rocket-launcher-reload.mp3 +0 -0
  17. package/examples/hygrounds/assets/audio/sfx/rocket-launcher-shoot.mp3 +0 -0
  18. package/examples/hygrounds/assets/audio/sfx/shield-potion-consume.mp3 +0 -0
  19. package/examples/hygrounds/assets/audio/sfx/shield.png +0 -0
  20. package/examples/hygrounds/assets/audio/sfx/shotgun-reload.mp3 +0 -0
  21. package/examples/hygrounds/assets/audio/sfx/shotgun-shoot.mp3 +0 -0
  22. package/examples/hygrounds/assets/audio/sfx/sniper-reload.mp3 +0 -0
  23. package/examples/hygrounds/assets/audio/sfx/sniper-shoot.mp3 +0 -0
  24. package/examples/hygrounds/assets/icons/ak-47.png +0 -0
  25. package/examples/hygrounds/assets/icons/ammo.png +0 -0
  26. package/examples/hygrounds/assets/icons/auto-shotgun.png +0 -0
  27. package/examples/hygrounds/assets/icons/block.png +0 -0
  28. package/examples/hygrounds/assets/icons/bolt-action-sniper.png +0 -0
  29. package/examples/hygrounds/assets/icons/crown-bronze.png +0 -0
  30. package/examples/hygrounds/assets/icons/crown-gold.png +0 -0
  31. package/examples/hygrounds/assets/icons/crown-silver.png +0 -0
  32. package/examples/hygrounds/assets/icons/heart.png +0 -0
  33. package/examples/hygrounds/assets/icons/light-machine-gun.png +0 -0
  34. package/examples/hygrounds/assets/icons/medpack.png +0 -0
  35. package/examples/hygrounds/assets/icons/mining-drill.png +0 -0
  36. package/examples/hygrounds/assets/icons/pickaxe.png +0 -0
  37. package/examples/hygrounds/assets/icons/pistol.png +0 -0
  38. package/examples/hygrounds/assets/icons/rocket-launcher.png +0 -0
  39. package/examples/hygrounds/assets/icons/shield-potion.png +0 -0
  40. package/examples/hygrounds/assets/icons/shield.png +0 -0
  41. package/examples/hygrounds/assets/icons/shotgun.png +0 -0
  42. package/examples/hygrounds/assets/map.json +31796 -0
  43. package/examples/hygrounds/assets/models/environment/.optimized/explosion/explosion-named-nodes.glb +0 -0
  44. package/examples/hygrounds/assets/models/environment/.optimized/explosion/explosion.glb +0 -0
  45. package/examples/hygrounds/assets/models/environment/.optimized/explosion/explosion.glb.md5 +1 -0
  46. package/examples/hygrounds/assets/models/environment/.optimized/explosion-2/explosion-2-named-nodes.glb +0 -0
  47. package/examples/hygrounds/assets/models/environment/.optimized/explosion-2/explosion-2.glb +0 -0
  48. package/examples/hygrounds/assets/models/environment/.optimized/explosion-2/explosion-2.glb.md5 +1 -0
  49. package/examples/hygrounds/assets/models/environment/.optimized/explosion-3/explosion-3-named-nodes.glb +0 -0
  50. package/examples/hygrounds/assets/models/environment/.optimized/explosion-3/explosion-3.glb +0 -0
  51. package/examples/hygrounds/assets/models/environment/.optimized/explosion-3/explosion-3.glb.md5 +1 -0
  52. package/examples/hygrounds/assets/models/environment/.optimized/helicopter/helicopter-named-nodes.glb +0 -0
  53. package/examples/hygrounds/assets/models/environment/.optimized/helicopter/helicopter.glb +0 -0
  54. package/examples/hygrounds/assets/models/environment/.optimized/helicopter/helicopter.glb.md5 +1 -0
  55. package/examples/hygrounds/assets/models/environment/chest.gltf +1 -0
  56. package/examples/hygrounds/assets/models/environment/explosion.glb +0 -0
  57. package/examples/hygrounds/assets/models/environment/muzzle-flash.gltf +1 -0
  58. package/examples/hygrounds/assets/models/items/.optimized/medkit/medkit-named-nodes.glb +0 -0
  59. package/examples/hygrounds/assets/models/items/.optimized/medkit/medkit.glb +0 -0
  60. package/examples/hygrounds/assets/models/items/.optimized/medkit/medkit.glb.md5 +1 -0
  61. package/examples/hygrounds/assets/models/items/.optimized/medpack/medpack-named-nodes.glb +0 -0
  62. package/examples/hygrounds/assets/models/items/.optimized/medpack/medpack.glb +0 -0
  63. package/examples/hygrounds/assets/models/items/.optimized/medpack/medpack.glb.md5 +1 -0
  64. package/examples/hygrounds/assets/models/items/.optimized/mining-drill/mining-drill-named-nodes.glb +0 -0
  65. package/examples/hygrounds/assets/models/items/.optimized/mining-drill/mining-drill.glb +0 -0
  66. package/examples/hygrounds/assets/models/items/.optimized/mining-drill/mining-drill.glb.md5 +1 -0
  67. package/examples/hygrounds/assets/models/items/.optimized/rocket-missile/rocket-missile-named-nodes.glb +0 -0
  68. package/examples/hygrounds/assets/models/items/.optimized/rocket-missile/rocket-missile.glb +0 -0
  69. package/examples/hygrounds/assets/models/items/.optimized/rocket-missile/rocket-missile.glb.md5 +1 -0
  70. package/examples/hygrounds/assets/models/items/.optimized/shield-potion/shield-potion-named-nodes.glb +0 -0
  71. package/examples/hygrounds/assets/models/items/.optimized/shield-potion/shield-potion.glb +0 -0
  72. package/examples/hygrounds/assets/models/items/.optimized/shield-potion/shield-potion.glb.md5 +1 -0
  73. package/examples/hygrounds/assets/models/items/.optimized/shield-potion-2/shield-potion-2-named-nodes.glb +0 -0
  74. package/examples/hygrounds/assets/models/items/.optimized/shield-potion-2/shield-potion-2.glb +0 -0
  75. package/examples/hygrounds/assets/models/items/.optimized/shield-potion-2/shield-potion-2.glb.md5 +1 -0
  76. package/examples/hygrounds/assets/models/items/ak-47.glb +0 -0
  77. package/examples/hygrounds/assets/models/items/auto-shotgun.glb +0 -0
  78. package/examples/hygrounds/assets/models/items/bolt-action-sniper.glb +0 -0
  79. package/examples/hygrounds/assets/models/items/light-machine-gun.glb +0 -0
  80. package/examples/hygrounds/assets/models/items/medpack.glb +0 -0
  81. package/examples/hygrounds/assets/models/items/mining-drill.glb +0 -0
  82. package/examples/hygrounds/assets/models/items/pickaxe.gltf +1 -0
  83. package/examples/hygrounds/assets/models/items/pistol.glb +0 -0
  84. package/examples/hygrounds/assets/models/items/rocket-launcher.glb +0 -0
  85. package/examples/hygrounds/assets/models/items/rocket-missile.glb +0 -0
  86. package/examples/hygrounds/assets/models/items/shield-potion.glb +0 -0
  87. package/examples/hygrounds/assets/models/items/shotgun.glb +0 -0
  88. package/examples/hygrounds/assets/models/players/soldier-player.gltf +1 -0
  89. package/examples/hygrounds/assets/ui/images/scope.png +0 -0
  90. package/examples/hygrounds/assets/ui/index.html +1072 -0
  91. package/examples/hygrounds/bun.lock +503 -0
  92. package/examples/hygrounds/classes/ChestEntity.ts +133 -0
  93. package/examples/hygrounds/classes/GameManager.ts +384 -0
  94. package/examples/hygrounds/classes/GamePlayerEntity.ts +564 -0
  95. package/examples/hygrounds/classes/GunEntity.ts +263 -0
  96. package/examples/hygrounds/classes/ItemEntity.ts +225 -0
  97. package/examples/hygrounds/classes/ItemFactory.ts +49 -0
  98. package/examples/hygrounds/classes/MeleeWeaponEntity.ts +138 -0
  99. package/examples/hygrounds/classes/TerrainDamageManager.ts +56 -0
  100. package/examples/hygrounds/classes/items/MedPackEntity.ts +43 -0
  101. package/examples/hygrounds/classes/items/ShieldPotionEntity.ts +43 -0
  102. package/examples/hygrounds/classes/weapons/AK47Entity.ts +43 -0
  103. package/examples/hygrounds/classes/weapons/AutoShotgunEntity.ts +80 -0
  104. package/examples/hygrounds/classes/weapons/BoltActionSniperEntity.ts +46 -0
  105. package/examples/hygrounds/classes/weapons/LightMachineGunEntity.ts +43 -0
  106. package/examples/hygrounds/classes/weapons/MiningDrillEntity.ts +38 -0
  107. package/examples/hygrounds/classes/weapons/PickaxeEntity.ts +38 -0
  108. package/examples/hygrounds/classes/weapons/PistolEntity.ts +46 -0
  109. package/examples/hygrounds/classes/weapons/RocketLauncherEntity.ts +186 -0
  110. package/examples/hygrounds/classes/weapons/ShotgunEntity.ts +84 -0
  111. package/examples/hygrounds/gameConfig.ts +398 -0
  112. package/examples/hygrounds/index.ts +40 -0
  113. package/examples/hygrounds/package.json +16 -0
  114. package/package.json +1 -1
  115. package/server.api.json +21 -0
  116. package/server.d.ts +2 -1
  117. package/server.js +113 -113
@@ -0,0 +1,84 @@
1
+ import { Quaternion, Vector3Like, QuaternionLike } from 'hytopia';
2
+ import GunEntity from '../GunEntity';
3
+ import type { GunEntityOptions } from '../GunEntity';
4
+ import type GamePlayerEntity from '../GamePlayerEntity';
5
+
6
+ const DEFAULT_SHOTGUN_OPTIONS: GunEntityOptions = {
7
+ ammo: 4,
8
+ damage: 12, // Per pellet (7 pellets = 84 max damage)
9
+ fireRate: 0.8,
10
+ heldHand: 'both',
11
+ iconImageUri: 'icons/shotgun.png',
12
+ idleAnimation: 'idle_gun_both',
13
+ mlAnimation: 'shoot_gun_both',
14
+ name: 'Shotgun',
15
+ maxAmmo: 4,
16
+ totalAmmo: 24,
17
+ modelUri: 'models/items/shotgun.glb',
18
+ modelScale: 1.2,
19
+ range: 8,
20
+ reloadAudioUri: 'audio/sfx/shotgun-reload.mp3',
21
+ reloadTimeMs: 3000,
22
+ shootAudioUri: 'audio/sfx/shotgun-shoot.mp3',
23
+ };
24
+
25
+ export default class ShotgunEntity extends GunEntity {
26
+ public constructor(options: Partial<GunEntityOptions> = {}) {
27
+ super({ ...DEFAULT_SHOTGUN_OPTIONS, ...options });
28
+ }
29
+
30
+ public override shoot(): void {
31
+ if (!this.parent || !this.processShoot()) return;
32
+
33
+ super.shoot();
34
+
35
+ // Cancel input since shotgun requires click-to-shoot
36
+ (this.parent as GamePlayerEntity).player.input.ml = false;
37
+ }
38
+
39
+ public override getMuzzleFlashPositionRotation(): { position: Vector3Like, rotation: QuaternionLike } {
40
+ return {
41
+ position: { x: 0.03, y: 0.1, z: -1.5 },
42
+ rotation: Quaternion.fromEuler(0, 90, 0),
43
+ };
44
+ }
45
+
46
+ public override shootRaycast(origin: Vector3Like, direction: Vector3Like, length: number) {
47
+ // Create spread pattern for shotgun pellets using angles relative to direction
48
+ const spreadAngles = [
49
+ { x: 0, y: 0 }, // Center
50
+ { x: 0.05, y: 0.05 }, // Upper right
51
+ { x: -0.05, y: 0.05 }, // Upper left
52
+ { x: 0.07, y: 0 }, // Right
53
+ { x: -0.07, y: 0 }, // Left
54
+ { x: 0.05, y: -0.05 }, // Lower right
55
+ { x: -0.05, y: -0.05 } // Lower left
56
+ ];
57
+
58
+ // Fire each pellet with spread applied to original direction
59
+ for (const angle of spreadAngles) {
60
+ // Calculate spread direction relative to original direction
61
+ const spreadDirection = {
62
+ x: direction.x + (direction.z * angle.x), // Add horizontal spread
63
+ y: direction.y + angle.y, // Add vertical spread
64
+ z: direction.z - (direction.x * angle.x) // Maintain direction magnitude
65
+ };
66
+
67
+ // Normalize the spread direction to maintain consistent range
68
+ const magnitude = Math.sqrt(
69
+ spreadDirection.x * spreadDirection.x +
70
+ spreadDirection.y * spreadDirection.y +
71
+ spreadDirection.z * spreadDirection.z
72
+ );
73
+
74
+ const normalizedDirection = {
75
+ x: spreadDirection.x / magnitude,
76
+ y: spreadDirection.y / magnitude,
77
+ z: spreadDirection.z / magnitude
78
+ };
79
+
80
+ super.shootRaycast(origin, normalizedDirection, length);
81
+ }
82
+ }
83
+ }
84
+
@@ -0,0 +1,398 @@
1
+ import { Quaternion } from 'hytopia';
2
+
3
+ export const BEDROCK_BLOCK_ID = 2;
4
+
5
+ export const BLOCK_ID_BREAK_DAMAGE: Record<string | number, number> = {
6
+ 1: 50, // bricks
7
+ 4: 50, // cobblestone
8
+ 6: 70, // diamond block
9
+ 7: 70, // diamond ore
10
+ 8: 10, // dirt
11
+ 14: 10, // glass
12
+ 15: 70, // gold ore
13
+ 16: 10, // grass
14
+ 17: 10, // gravel
15
+ 19: 100, // infected shadowrock core
16
+ 20: 100, // infected shadowrock
17
+ 24: 50, // mossy cobblestone
18
+ 27: 10, // oak leaves
19
+ 30: 10, // sand
20
+ 36: 100, // stone bricks
21
+ 37: 40, // stone (also build block)
22
+ default: 30, // default for all other blocks
23
+ }
24
+
25
+ export const BLOCK_ID_MATERIALS: Record<string | number, number> = {
26
+ 1: 4, // bricks
27
+ 2: 0, // bedrock
28
+ 6: 10, // diamond block
29
+ 7: 10, // diamond ore,
30
+ 8: 0, // dirt
31
+ 14: 0, // glass
32
+ 15: 8, // gold ore,
33
+ 16: 0, // grass
34
+ 19: 8, // infected shadowrock core
35
+ 20: 8, // infected shadowrock
36
+ 22: 0, // lava
37
+ 23: 2, // log
38
+ 28: 2, // oak planks
39
+ 36: 5, // stone bricks
40
+ 42: 0, // water flow
41
+ 43: 0, // water still
42
+ default: 1, // default for all other blocks
43
+ };
44
+
45
+ export const BUILD_BLOCK_ID = 37; // stone
46
+
47
+ export const CHEST_DROP_INTERVAL_MS = 20 * 1000; // 20 seconds
48
+
49
+ export const CHEST_DROP_REGION_AABB = {
50
+ min: { x: -45, y: 100, z: -45 },
51
+ max: { x: 45, y: 100, z: 45 },
52
+ };
53
+
54
+ export const CHEST_SPAWNS_AT_START = 15;
55
+
56
+ export const CHEST_MAX_DROP_ITEMS = 2;
57
+
58
+ export const CHEST_OPEN_DESPAWN_MS = 20 * 1000; // 20 seconds
59
+
60
+ export const CHEST_DROP_ITEMS = [
61
+ {
62
+ itemId: 'ak47',
63
+ pickWeight: 0.4,
64
+ },
65
+ {
66
+ itemId: 'auto-shotgun',
67
+ pickWeight: 0.5,
68
+ },
69
+ {
70
+ itemId: 'bolt-action-sniper',
71
+ pickWeight: 0.6,
72
+ },
73
+ {
74
+ itemId: 'light-machine-gun',
75
+ pickWeight: 0.3,
76
+ },
77
+ {
78
+ itemId: 'medpack',
79
+ pickWeight: 1,
80
+ },
81
+ {
82
+ itemId: 'mining-drill',
83
+ pickWeight: 0.4,
84
+ },
85
+ {
86
+ itemId: 'pistol',
87
+ pickWeight: 1,
88
+ },
89
+ {
90
+ itemId: 'rocket-launcher',
91
+ pickWeight: 0.2,
92
+ },
93
+ {
94
+ itemId: 'shotgun',
95
+ pickWeight: 0.5,
96
+ },
97
+ {
98
+ itemId: 'shield-potion',
99
+ pickWeight: 1,
100
+ },
101
+ ]
102
+
103
+ export const CHEST_SPAWNS = [
104
+ {
105
+ position: { x: -14, y: 2, z: -16 },
106
+ rotation: Quaternion.fromEuler(0, -90, 0),
107
+ },
108
+ {
109
+ position: { x: -14, y: 2, z: -25 },
110
+ rotation: Quaternion.fromEuler(0, 90, 0),
111
+ },
112
+ {
113
+ position: { x: -36, y: 2, z: -34.5},
114
+ rotation: Quaternion.fromEuler(0, 180, 0),
115
+ },
116
+ {
117
+ position: { x: -30.5, y: 6, z: -33 },
118
+ rotation: Quaternion.fromEuler(0, -90, 0),
119
+ },
120
+ {
121
+ position: { x: -8, y: 2, z: -40 },
122
+ rotation: Quaternion.fromEuler(0, 180, 0),
123
+ },
124
+ {
125
+ position: { x: 38, y: 2, z: -18 },
126
+ rotation: Quaternion.fromEuler(0, 0, 0),
127
+ },
128
+ {
129
+ position: { x: 47, y: 2, z: -33 },
130
+ rotation: Quaternion.fromEuler(0, 90, 0),
131
+ },
132
+ {
133
+ position: { x: 41, y: 5, z: -46.5 },
134
+ rotation: Quaternion.fromEuler(0, 180, 0),
135
+ },
136
+ {
137
+ position: { x: 39.5, y: 4, z: 9 },
138
+ rotation: Quaternion.fromEuler(0, 90, 0),
139
+ },
140
+ {
141
+ position: { x: -2.5, y: 3, z: 13 },
142
+ rotation: Quaternion.fromEuler(0, 180, 0),
143
+ },
144
+ {
145
+ position: { x: 5.5, y: 3, z: 13 },
146
+ rotation: Quaternion.fromEuler(0, 0, 0),
147
+ },
148
+ {
149
+ position: { x: -2.5, y: 3, z: 8 },
150
+ rotation: Quaternion.fromEuler(0, 180, 0),
151
+ },
152
+ {
153
+ position: { x: 5.5, y: 3, z: 8 },
154
+ rotation: Quaternion.fromEuler(0, 0, 0),
155
+ },
156
+ {
157
+ position: { x: 35, y: 15, z: 34.5 },
158
+ rotation: Quaternion.fromEuler(0, 0, 0),
159
+ },
160
+ {
161
+ position: { x: 33.5, y: 3, z: 29 },
162
+ rotation: Quaternion.fromEuler(0, 90, 0),
163
+ },
164
+ {
165
+ position: { x: 40.5, y: 3, z: 31 },
166
+ rotation: Quaternion.fromEuler(0, 0, 0),
167
+ },
168
+ {
169
+ position: { x: 45, y: 3, z: 45 },
170
+ rotation: Quaternion.fromEuler(0, 0, 0),
171
+ },
172
+ {
173
+ position: { x: 9, y: 3, z: 40 },
174
+ rotation: Quaternion.fromEuler(0, 0, 0),
175
+ },
176
+ {
177
+ position: { x: -22.5, y: 3, z: 44 },
178
+ rotation: Quaternion.fromEuler(0, -90, 0),
179
+ },
180
+ {
181
+ position: { x: -14, y: 3, z: 42.5 },
182
+ rotation: Quaternion.fromEuler(0, 0, 0),
183
+ },
184
+ {
185
+ position: { x: -18, y: 8, z: 45 },
186
+ rotation: Quaternion.fromEuler(0, -90, 0),
187
+ },
188
+ {
189
+ position: { x: -22.5, y: 8, z: 46 },
190
+ rotation: Quaternion.fromEuler(0, -90, 0),
191
+ },
192
+ {
193
+ position: { x: -33.5, y: 3, z: 47 },
194
+ rotation: Quaternion.fromEuler(0, -90, 0),
195
+ },
196
+ {
197
+ position: { x: -44.5, y: 3, z: 23.5 },
198
+ rotation: Quaternion.fromEuler(0, 180, 0),
199
+ },
200
+ {
201
+ position: { x: -29, y: 3, z: 14 },
202
+ rotation: Quaternion.fromEuler(0, 90, 0),
203
+ },
204
+ {
205
+ position: { x: -32, y: 3, z: 21 },
206
+ rotation: Quaternion.fromEuler(0, -90, 0),
207
+ },
208
+ {
209
+ position: { x: -36, y: 3, z: 5.5 },
210
+ rotation: Quaternion.fromEuler(0, 0, 0),
211
+ },
212
+ {
213
+ position: { x: -12, y: 15, z: 27 },
214
+ rotation: Quaternion.fromEuler(0, 90, 0),
215
+ },
216
+ {
217
+ position: { x: -33.5, y: 20, z: 5.5 },
218
+ rotation: Quaternion.fromEuler(0, 90, 0),
219
+ },
220
+ {
221
+ position: { x: -24, y: 3, z: -8 },
222
+ rotation: Quaternion.fromEuler(0, 180, 0),
223
+ },
224
+ {
225
+ position: { x: -15.5, y: 3, z: 0 },
226
+ rotation: Quaternion.fromEuler(0, -90, 0),
227
+ },
228
+ {
229
+ position: { x: -14, y: 3, z: 5 },
230
+ rotation: Quaternion.fromEuler(0, 180, 0),
231
+ },
232
+ {
233
+ position: { x: 10, y: 3, z: -16 },
234
+ rotation: Quaternion.fromEuler(0, 0, 0),
235
+ },
236
+ {
237
+ position: { x: 18, y: 15, z: 4 },
238
+ rotation: Quaternion.fromEuler(0, 0, 0),
239
+ },
240
+ {
241
+ position: { x: -5.5, y: 3, z: 11.5 },
242
+ rotation: Quaternion.fromEuler(0, 0, 0),
243
+ },
244
+ {
245
+ position: { x: -12, y: 9, z: 3.5 },
246
+ rotation: Quaternion.fromEuler(0, 180, 0),
247
+ },
248
+ {
249
+ position: { x: 4, y: 9, z: 8 },
250
+ rotation: Quaternion.fromEuler(0, 180, 0),
251
+ },
252
+ {
253
+ position: { x: 17, y: 3, z: 16.5 },
254
+ rotation: Quaternion.fromEuler(0, 180, 0),
255
+ },
256
+ {
257
+ position: { x: 25, y: 3, z: 3.5 },
258
+ rotation: Quaternion.fromEuler(0, 180, 0),
259
+ },
260
+ {
261
+ position: { x: 24, y: 3, z: -13.5 },
262
+ rotation: Quaternion.fromEuler(0, 0, 0),
263
+ },
264
+ {
265
+ position: { x: 26.5, y: 3, z: -46.5 },
266
+ rotation: Quaternion.fromEuler(0, 90, 0),
267
+ },
268
+ {
269
+ position: { x: -44, y: 3, z: -46 },
270
+ rotation: Quaternion.fromEuler(0, 180, 0),
271
+ },
272
+ {
273
+ position: { x: 11, y: 9, z: -40 },
274
+ rotation: Quaternion.fromEuler(0, 180, 0),
275
+ },
276
+ {
277
+ position: { x: 3, y: 6, z: -19 },
278
+ rotation: Quaternion.fromEuler(0, 180, 0),
279
+ },
280
+ {
281
+ position: { x: 0.5, y: 3, z: -43.5 },
282
+ rotation: Quaternion.fromEuler(0, 180, 0),
283
+ },
284
+ {
285
+ position: { x: -42.5, y: 3, z: -18.5 },
286
+ rotation: Quaternion.fromEuler(0, 180, 0),
287
+ },
288
+ {
289
+ position: { x: -32.5, y: 3, z: -46.5 },
290
+ rotation: Quaternion.fromEuler(0, 90, 0),
291
+ },
292
+ {
293
+ position: { x: 40, y: 15, z: -18 },
294
+ rotation: Quaternion.fromEuler(0, 0, 0),
295
+ },
296
+ {
297
+ position: { x: 13, y: 3, z: 1 },
298
+ rotation: Quaternion.fromEuler(0, 0, 0),
299
+ },
300
+ {
301
+ position: { x: 7, y: 5, z: 36.5 },
302
+ rotation: Quaternion.fromEuler(0, 0, 0),
303
+ },
304
+ {
305
+ position: { x: -14, y: 9, z: -21 },
306
+ rotation: Quaternion.fromEuler(0, 0, 0),
307
+ },
308
+ {
309
+ position: { x: -33, y: 15, z: -35.5 },
310
+ rotation: Quaternion.fromEuler(0, 90, 0),
311
+ },
312
+ {
313
+ position: { x: -28, y: 15, z: -35.5 },
314
+ rotation: Quaternion.fromEuler(0, 90, 0),
315
+ },
316
+ {
317
+ position: { x: -23, y: 3, z: 2.5 },
318
+ rotation: Quaternion.fromEuler(0, 90, 0),
319
+ },
320
+ {
321
+ position: { x: -6, y: 5, z: 22 },
322
+ rotation: Quaternion.fromEuler(0, 180, 0),
323
+ },
324
+ ];
325
+
326
+ export const GAME_DURATION_MS = 10 * 60 * 1000; // 10 minutes
327
+
328
+ export const ITEM_DESPAWN_TIME_MS = 30 * 1000; // 30 seconds
329
+
330
+ export const ITEM_SPAWNS = [
331
+ { position: { x: -21.5, y: 2, z: -17 } },
332
+ { position: { x: -28.5, y: 7, z: -35.5 } },
333
+ { position: { x: -19.5, y: 2, z: -46.5 } },
334
+ { position: { x: -37.5, y: 2, z: -3.5 } },
335
+ { position: { x: -31.5, y: 2, z: 16.5 } },
336
+ { position: { x: -18.5, y: 2, z: 40.5 } },
337
+ { position: { x: 1.5, y: 2, z: 11.5 } },
338
+ { position: { x: 7.5, y: 10, z: 36.5 } },
339
+ { position: { x: 20.5, y: 2, z: 44.5 } },
340
+ { position: { x: 37.5, y: 2, z: 38.5 } },
341
+ { position: { x: 44.5, y: 2, z: -3.5 } },
342
+ { position: { x: 37.5, y: 2, z: -17.5 } },
343
+ { position: { x: 40.5, y: 10, z: -41.5 } },
344
+ { position: { x: 3.5, y: 10, z: -31.5 } },
345
+ { position: { x: -30.5, y: 10, z: 41.5 } },
346
+ ];
347
+
348
+ export const ITEM_SPAWN_ITEMS = [
349
+ {
350
+ itemId: 'ak47',
351
+ pickWeight: 0.05,
352
+ },
353
+ {
354
+ itemId: 'auto-shotgun',
355
+ pickWeight: 0.05,
356
+ },
357
+ {
358
+ itemId: 'bolt-action-sniper',
359
+ pickWeight: 0.05,
360
+ },
361
+ {
362
+ itemId: 'light-machine-gun',
363
+ pickWeight: 0.05,
364
+ },
365
+ {
366
+ itemId: 'medpack',
367
+ pickWeight: 1,
368
+ },
369
+ {
370
+ itemId: 'mining-drill',
371
+ pickWeight: 0.05,
372
+ },
373
+ {
374
+ itemId: 'pistol',
375
+ pickWeight: 1,
376
+ },
377
+ {
378
+ itemId: 'rocket-launcher',
379
+ pickWeight: 0.03,
380
+ },
381
+ {
382
+ itemId: 'shotgun',
383
+ pickWeight: 0.08,
384
+ },
385
+ {
386
+ itemId: 'shield-potion',
387
+ pickWeight: 1,
388
+ },
389
+ ];
390
+
391
+ export const ITEM_SPAWNS_AT_START = 8;
392
+
393
+ export const MINIMUM_PLAYERS_TO_START = 2;
394
+
395
+ export const SPAWN_REGION_AABB = {
396
+ min: { x: -45, y: 30, z: -45 },
397
+ max: { x: 45, y: 35, z: 45 },
398
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ startServer,
3
+ PlayerEvent,
4
+ } from 'hytopia';
5
+
6
+ import GameManager from './classes/GameManager';
7
+
8
+ import worldMap from './assets/map.json';
9
+
10
+ startServer(world => {
11
+ // Load the game map
12
+ world.loadMap(worldMap);
13
+
14
+ // Set lighting
15
+ world.setAmbientLightIntensity(0.8);
16
+ world.setDirectionalLightIntensity(5);
17
+
18
+ GameManager.instance.setupGame(world);
19
+
20
+ // Handle player joining the game
21
+ world.on(PlayerEvent.JOINED_WORLD, ({ player }) => {
22
+ GameManager.instance.spawnPlayerEntity(player);
23
+ GameManager.instance.playerCount++;
24
+ });
25
+
26
+ // Handle player leaving the game
27
+ world.on(PlayerEvent.LEFT_WORLD, ({ player }) => {
28
+ // Clean up player entities
29
+ world.entityManager
30
+ .getPlayerEntitiesByPlayer(player)
31
+ .forEach(entity => entity.despawn());
32
+
33
+ GameManager.instance.playerCount--;
34
+ });
35
+ });
36
+
37
+
38
+ /*
39
+ - fix zoom of SMG
40
+ */
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "zombies-fps",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "@hytopia.com/assets": "latest",
14
+ "hytopia": "latest"
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.api.json CHANGED
@@ -26358,6 +26358,27 @@
26358
26358
  "releaseTag": "Public",
26359
26359
  "name": "FIRST_PERSON"
26360
26360
  },
26361
+ {
26362
+ "kind": "EnumMember",
26363
+ "canonicalReference": "server!PlayerCameraMode.SPECTATOR:member",
26364
+ "docComment": "",
26365
+ "excerptTokens": [
26366
+ {
26367
+ "kind": "Content",
26368
+ "text": "SPECTATOR = "
26369
+ },
26370
+ {
26371
+ "kind": "Content",
26372
+ "text": "2"
26373
+ }
26374
+ ],
26375
+ "initializerTokenRange": {
26376
+ "startIndex": 1,
26377
+ "endIndex": 2
26378
+ },
26379
+ "releaseTag": "Public",
26380
+ "name": "SPECTATOR"
26381
+ },
26361
26382
  {
26362
26383
  "kind": "EnumMember",
26363
26384
  "canonicalReference": "server!PlayerCameraMode.THIRD_PERSON:member",
package/server.d.ts CHANGED
@@ -3367,7 +3367,8 @@ export declare interface PlayerCameraEventPayloads {
3367
3367
  /** The mode of the camera. @public */
3368
3368
  export declare enum PlayerCameraMode {
3369
3369
  FIRST_PERSON = 0,
3370
- THIRD_PERSON = 1
3370
+ THIRD_PERSON = 1,
3371
+ SPECTATOR = 2
3371
3372
  }
3372
3373
 
3373
3374
  /** The camera orientation state of a Player. @public */