-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathconfig.py
More file actions
539 lines (493 loc) · 15.6 KB
/
Copy pathconfig.py
File metadata and controls
539 lines (493 loc) · 15.6 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
"""
PyTanks Game Configuration
All game parameters in one place for easy tuning and balancing
"""
# =============================================================================
# NETWORK SETTINGS
# =============================================================================
SERVER_PORT = 5555
SERVER_HOST = "192.168.56.1" # Change to your server IP
# =============================================================================
# MAP SETTINGS
# =============================================================================
MAP_OPTIONS = ["catacombs", "outpost"]
ACTIVE_MAP_INDEX = 0 # 0=catacombs, 1=outpost
DEFAULT_MAP = MAP_OPTIONS[ACTIVE_MAP_INDEX]
GRID_SIZE = 16 # Each grid cell is 16x16 pixels
# =============================================================================
# MATCH SETTINGS
# =============================================================================
MATCH_DURATION = 180.0 # seconds
# =============================================================================
# PLAYER/TANK SETTINGS
# =============================================================================
# Movement
TANK_SPEED = 3.0
KNEEL_SPEED_MULTIPLIER = 0.1 # Movement speed multiplier while kneeling
TANK_ROTATION_SPEED = 0.04
TANK_VISUAL_RADIUS = 7.5
TANK_COLLISION_RADIUS = 6 # Smaller to prevent getting stuck
PLAYER_HITBOX_WIDTH = 30.0
PLAYER_HITBOX_HEIGHT = 45.0
KNEEL_HEIGHT_DELTA = 15.0 # Reduce active player height by 5 while kneeling
# Aiming
AIM_ROTATION_SPEED = 0.04 # Radians per frame (reduced for smoother keyboard aiming)
# Health
MAX_HEALTH = 200.0
HEALTH_REGEN_ENABLED = True
HEALTH_REGEN_PER_SECOND = 2.0 # Slow linear regeneration for alive players
# --- Local multi-client setup ---
# If True → first client is keyboard-controlled and rendered
# If False → only script bots run
ENABLE_KEYBOARD_PLAYER = False
# List of bot script filenames (without .py)
BOT_SCRIPTS = [
"pro_bot",
"pro_bot",
"pro_bot",
"pro_bot",
"pro_bot",
"pro_bot",
"pro_bot",
"pro_bot"
]
# If no keyboard player, first script bot renders
RENDER_FIRST_BOT = True
# Colors
PLAYER_COLOR = (255, 0, 0) # Red for other players
SELF_COLOR = (0, 0, 255) # Blue for yourself
# Debug rendering
SHOW_DEBUG_HITBOX = False
DEBUG_HITBOX_ALPHA = 90
# =============================================================================
# PHYSICS SETTINGS
# =============================================================================
GRAVITY = 0.6
# Jetpack System
MAX_FUEL = 100.0
FUEL_CONSUMPTION = 0.5 # Fuel consumed per frame when active
FUEL_RECHARGE = 0.5 # Fuel recharged per frame when inactive
JETPACK_THRUST = 0.8 # Upward velocity applied
KNEEL_JUMP_IMPULSE = 5.0 # Small one-tap jump strength while kneeling (no flight)
# =============================================================================
# BULLET SETTINGS
# =============================================================================
BULLET_SPEED = 10.0
MAX_BULLET_DISTANCE = 1200 # Max travel distance before deactivation
BULLET_VISUAL_RADIUS = 100
# =============================================================================
# GUN WEAPON STATS
# Structured dictionary for clarity and future expansion
# =============================================================================
WEAPON_STATS = {
0: {
"name": "AK47",
"damage": 45,
"accuracy": 4,
"reload_time": 2.5,
"melee": 30,
"rpf": 1,
"effective_range": 800,
"dual_wielding": False,
"rate_of_fire": 0.1,
"magazine_capacity": 35,
"ammo_given": 250,
"sprite_file": "ak47.png",
"bullet_speed": 60,
"scope": 4.0,
},
1: {
"name": "Desert Eagle",
"damage": 20,
"accuracy": 2,
"reload_time": 1.5,
"melee": 15,
"rpf": 1,
"effective_range": 500,
"dual_wielding": False,
"rate_of_fire": 0.25,
"magazine_capacity": 15,
"ammo_given": 75,
"sprite_file": "Minieagle.png",
"bullet_speed": 70,
"scope": 2.0,
},
2: {
"name": "Golden Deagle",
"damage": 30,
"accuracy": 2,
"reload_time": 1.5,
"melee": 25,
"rpf": 1,
"effective_range": 600,
"dual_wielding": False,
"rate_of_fire": 0.2,
"magazine_capacity": 15,
"ammo_given": 75,
"sprite_file": "gdeagle.png",
"bullet_speed": 70,
"scope": 4.0,
},
3: {
"name": "M14",
"damage": 100,
"accuracy": 0,
"reload_time": 3,
"melee": 35,
"rpf": 1,
"effective_range": 1200,
"dual_wielding": False,
"rate_of_fire": 0.55,
"scope": 4.0,
"magazine_capacity": 6,
"ammo_given": 36,
"sprite_file": "M14.png",
"bullet_speed": 80,
},
4: {
"name": "M4",
"damage": 40,
"accuracy": 2,
"reload_time": 2.5,
"melee": 30,
"rpf": 1,
"effective_range": 1000,
"dual_wielding": False,
"rate_of_fire": 0.5,
"magazine_capacity": 24,
"ammo_given": 300,
"sprite_file": "M4.png",
"bullet_speed": 75,
"scope": 5.0,
},
5: {
"name": "M93BA Sniper",
"damage": 200,
"accuracy": 0,
"reload_time": 3.5,
"melee": 35,
"rpf": 1,
"effective_range": 1500,
"dual_wielding": False,
"rate_of_fire": 0.8,
"magazine_capacity": 3,
"ammo_given": 20,
"sprite_file": "Sniper.png",
"bullet_speed": 100,
"scope": 7.0,
},
6: {
"name": "Magnum",
"damage": 30,
"accuracy": 1,
"reload_time": 2.5,
"melee": 25,
"rpf": 1,
"effective_range": 650,
"dual_wielding": False,
"rate_of_fire": 0.6,
"magazine_capacity": 6,
"ammo_given": 36,
"sprite_file": "magnum.png",
"bullet_speed": 75,
"scope": 2.0,
},
7: {
"name": "MP5",
"damage": 25,
"accuracy": 5,
"reload_time": 2,
"melee": 30,
"rpf": 1,
"effective_range": 700,
"dual_wielding": True,
"rate_of_fire": 0.06,
"magazine_capacity": 50,
"ammo_given": 400,
"sprite_file": "mp5.png",
"bullet_speed": 65,
"scope": 4.0,
},
8: {
"name": "UZI",
"damage": 25,
"accuracy": 6,
"reload_time": 1.8,
"melee": 20,
"rpf": 1,
"effective_range": 500,
"dual_wielding": True,
"rate_of_fire": 0.1,
"magazine_capacity": 40,
"ammo_given": 400,
"sprite_file": "Uzi.png",
"bullet_speed": 60,
"scope": 4.0,
},
9: {
"name": "TEC9",
"damage": 25,
"accuracy": 4,
"reload_time": 1.8,
"melee": 25,
"rpf": 1,
"effective_range": 600,
"dual_wielding": True,
"rate_of_fire": 0.15,
"magazine_capacity": 40,
"ammo_given": 400,
"sprite_file": "Tec-9.png",
"bullet_speed": 65,
"scope": 4.0,
},
10: {
"name": "SPAS-12",
"damage": 75,
"accuracy": 10,
"reload_time": 3.5,
"melee": 40,
"rpf": 5,
"effective_range": 325,
"dual_wielding": False,
"rate_of_fire": 0.75,
"magazine_capacity": 5,
"ammo_given": 24,
"sprite_file": "Shotgun.png",
"bullet_speed": 55,
"scope": 2.0,
},
11: {
"name": "SAW",
"damage": 100,
"accuracy": 0,
"reload_time": 5,
"melee": 35,
"rpf": 1,
"effective_range": 1000,
"dual_wielding": False,
"rate_of_fire": 1.25,
"magazine_capacity": 3,
"ammo_given": 6,
"sprite_file": "saw.png",
"bullet_speed": 3.0,
"scope": 4.0,
},
12: {
"name": "TAVOR",
"damage": 9,
"accuracy": 2,
"reload_time": 2,
"melee": 30,
"rpf": 1,
"effective_range": 750,
"dual_wielding": False,
"rate_of_fire": 0.12,
"magazine_capacity": 35,
"ammo_given": 200,
"sprite_file": "tavor.png",
"bullet_speed": 70,
"scope": 5.0,
},
13: {
"name": "XM8",
"damage": 8,
"accuracy": 3.25,
"reload_time": 2.2,
"melee": 30,
"rpf": 1,
"effective_range": 875,
"dual_wielding": False,
"rate_of_fire": 0.085,
"magazine_capacity": 30,
"ammo_given": 200,
"sprite_file": "XM8.png",
"bullet_speed": 72,
"scope": 5.0,
},
14: {
"name": "MINIGUN",
"damage": 30,
"accuracy": 7,
"reload_time": 4.5,
"melee": 35,
"rpf": 1,
"effective_range": 650,
"dual_wielding": False,
"rate_of_fire": 0.08,
"magazine_capacity": 50,
"ammo_given": 200,
"sprite_file": "minigun.png",
"bullet_speed": 68,
"scope": 4.0,
},
15: {
"name": "ROCKET_LAUNCHER",
"damage": 100,
"accuracy": 10,
"reload_time": 4,
"melee": 40,
"rpf": 1,
"effective_range": 1200,
"dual_wielding": False,
"rate_of_fire": 0.5,
"magazine_capacity": 3,
"ammo_given": 12,
"sprite_file": "rocket_launcher.png",
"bullet_speed": 3.0,
"scope": 6.0,
},
}
# =============================================================================
# GUN SPAWN SYSTEM
# =============================================================================
GUN_SPAWN_INTERVAL = 30 # Seconds before gun respawns
GUN_PICKUP_RADIUS = 20.0 # Distance to pick up gun
MAX_GUNS_PER_PLAYER = 2 # Inventory size
DEFAULT_STARTING_WEAPON = 1 # Desert Eagle
DEFAULT_SECONDARY_WEAPON = 2 # Golden Deagle (slot 2)
GUN_SPAWN_APPEAR_CHANCE = 0.5 # Chance that a gun spawn appears when a spawn attempt happens
GUN_SPAWN_ACTIVE_LIFETIME = 60.0 # Seconds before an unpicked gun despawns
# Starting weapon pool: (weapon_id, weight) — weights are relative probabilities
# id 1 = Desert Eagle (40%), id 8 = Uzi (30%), id 9 = Tec-9 (30%)
STARTING_WEAPON_POOL = [(1, 40), (8, 30), (9, 30)]
def get_random_starting_weapon():
"""Return a random starting weapon ID according to STARTING_WEAPON_POOL weights."""
import random
ids, weights = zip(*STARTING_WEAPON_POOL)
return random.choices(ids, weights=weights, k=1)[0]
# =============================================================================
# GRENADE DATA
# =============================================================================
FRAG_GRENADE_COUNT = 2 # Number of frag grenades given on spawn
PROXY_GRENADE_COUNT = 1 # Number of proximity grenades given on spawn
GAS_GREANADE_COUNT = 1 # Number of gas grenades given on spawn
# Gun spawn locations per map
# Format: (x, y, weapon_id)
GUN_SPAWN_POINTS = {
"catacombs": [
# Left side spawns
(100, 300, 1), # Desert Eagle
(150, 450, 8), # UZI
(200, 150, 7), # MP5
# Center spawns
(400, 250, 0), # AK47
(450, 400, 10), # Shotgun
(500, 100, 4), # M4
# Right side spawns
(700, 300, 5), # Sniper
(650, 450, 3), # M14
(750, 150, 11), # SAW
# Additional spawns
(300, 500, 6), # Magnum
(600, 500, 12), # TAVOR
(350, 50, 13), # XM8
],
# Add more maps here
# "arena": [...],
# "open": [...],
}
# =============================================================================
# MEDKIT SPAWN SETTINGS
# =============================================================================
MEDKIT_SPAWN_INTERVAL = 10.0 # Time before medkit respawns (in seconds)
MEDKIT_PICKUP_RADIUS = 20.0 # Distance to pick up medkit
MEDKIT_SPAWN_APPEAR_CHANCE = 0.4 # Chance that a medkit spawn appears when a spawn attempt happens
MEDKIT_SPAWN_ACTIVE_LIFETIME = 60.0 # Seconds before an unpicked medkit despawns
# Medkit spawn locations per map
# Format: (x, y)
MEDKIT_SPAWN_POINTS = {
"catacombs": [
(250, 250), # Left area
(450, 300), # Center area
(700, 250), # Right area
],
# Add more maps here
# "arena": [...],
# "open": [...],
}
# =============================================================================
# RENDERING SETTINGS
# =============================================================================
GAME_FPS = 30 # Client FPS
SERVER_FPS = 60 # Server tick rate
# Background Colors
BACKGROUND_COLOR = (101, 67, 33) # Brown background
OBSTACLE_COLOR = (210, 180, 140) # Light brown/yellowish blocks
OBSTACLE_BORDER_COLOR = (160, 130, 90)
# Gun Spawn Visual
GUN_SPAWN_GLOW_COLOR = (255, 215, 0) # Gold
GUN_SPAWN_SCALE = 25 # Size of spawned gun (matching player size)
# Projectile / grenade visual sizes
BULLET_VISUAL_SIZE = 6
SAW_BULLET_VISUAL_SIZE = 20
GRENADE_VISUAL_SIZE = 10
PROXY_GRENADE_VISUAL_SIZE = 20
# =============================================================================
# INPUT INDICES
# =============================================================================
# Player input array indices
INPUT_JETPACK = 0
INPUT_MOVE_LEFT = 1
INPUT_MOVE_RIGHT = 2
INPUT_AIM_UP = 3
INPUT_AIM_DOWN = 4
INPUT_AIM_LEFT = 5
INPUT_AIM_RIGHT = 6
INPUT_SHOOT = 7
INPUT_RELOAD = 8
INPUT_SWITCH_GUN = 9
# =============================================================================
# WORLD DATA INDICES (for network protocol)
# =============================================================================
# Tank columns (rows 0-7)
WORLD_IS_ALIVE = 0
WORLD_X = 1
WORLD_Y = 2
WORLD_THETA = 3
WORLD_V = 4
WORLD_OMEGA = 5
WORLD_FUEL = 6
WORLD_HEALTH = 7
WORLD_SCORE = 8
WORLD_CURRENT_AMMO = 9
WORLD_TOTAL_AMMO = 10
# Bullet columns (rows 8-47)
# Uses same indices but some have different meanings:
# WORLD_V = bullet speed
# WORLD_OMEGA = distance traveled
# WORLD_HEALTH = damage
# WORLD_CURRENT_AMMO = owner id
# =============================================================================
# GAME MECHANICS
# =============================================================================
BULLET_HIT_RADIUS = 25 # Collision detection radius for bullets vs players
# SAW weapon settings
SAW_WEAPON_ID = 11
SAW_LIFETIME = 5 # Seconds a saw projectile stays alive
SAW_EXPLOSION_RADIUS = 60.0 # Small frag-like blast on saw timeout
SAW_EXPLOSION_DAMAGE = 300.0
SAW_SELF_HIT_ARM_DISTANCE = 35.0 # Must travel this far before it can hurt the shooter
SAW_FIRE_DELAY = 2.0 # Hold fire key this long before SAW bullet is released
RESPAWN_WITH_FULL_FUEL = True
RESPAWN_WITH_FULL_HEALTH = True
RESPAWN_DELAY = 5.0 # Seconds to wait before respawning after death
# Rocket Launcher settings
ROCKET_LAUNCHER_ID = 15
ROCKET_EXPLOSION_RADIUS = 80.0
ROCKET_EXPLOSION_DAMAGE = 500.0
# =============================================================================
# HELPER FUNCTIONS
# =============================================================================
def get_weapon_stat(weapon_id, stat_name):
"""Get a specific stat for a weapon by name"""
if weapon_id not in WEAPON_STATS:
return None
if stat_name not in WEAPON_STATS[weapon_id]:
return None
return WEAPON_STATS[weapon_id][stat_name]
def get_all_weapon_ids():
"""Get list of all weapon IDs"""
return list(WEAPON_STATS.keys())
def get_spawn_points_for_map(map_name):
"""Get spawn points for a specific map"""
return GUN_SPAWN_POINTS.get(map_name, [])