group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
WeaponConfig.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "CollisionShape.hpp"
8
9#include <array>
10#include <cstddef>
11
14{
15 float fireCooldown = 0.1f;
16 int magazineSize = 0;
18 float damage = 0.0f;
19 bool hitscan = true;
21 bool explosive = false;
22 bool isBeam = false;
23 bool isCharge = false;
24 float dps = 0.0f;
25 float ammoPerSecond = 0.0f;
26 float chargeDamage = 0.0f;
27 float maxChargeTime = 0.0f;
28};
29
31{
32 int modelId = 0;
33 float initialSpeed = 0.0f;
34 float scale = 1.0f;
35 CollisionShape shape = CollisionShape{.halfExtents = {5.0f, 5.0f, 5.0f}};
36 float maxLifeTime = 5.0f;
37 float explosionRadius = 0.0f;
47 float maxKnockback = 0.0f;
52};
53
56{
57 static constexpr std::array<WeaponConfig, 7> k_kWeaponConfigs{{
59 .fireCooldown = 0.10f,
60 .magazineSize = 50,
61 .defaultAmmoCapacity = 500,
62 .damage = 15.0f,
63 .hitscan = true,
64 .initialProjectileSpeed = 0.0f,
65 .explosive = false,
66 }, // Rifle
68 .fireCooldown = 1.0f,
69 .magazineSize = 4,
70 .defaultAmmoCapacity = 12,
71 .damage = 200.0f,
72 .hitscan = false,
73 .initialProjectileSpeed = 3000.0f,
74 .explosive = true,
75 }, // Rocket
77 .fireCooldown = 0.5f,
78 .magazineSize = 8,
79 .defaultAmmoCapacity = 32,
80 .damage = 50.0f,
81 .hitscan = true,
82 .initialProjectileSpeed = 0.0f,
83 .explosive = false,
84 .isCharge = true,
85 .chargeDamage = 80.0f,
86 .maxChargeTime = 1.0f,
87 }, // RailGun
89 .fireCooldown = 0.0f,
90 .magazineSize = 200,
91 .defaultAmmoCapacity = 200,
92 .damage = 5.0f,
93 .hitscan = true,
94 .initialProjectileSpeed = 0.0f,
95 .explosive = false,
96 .isBeam = true,
97 .dps = 80.0f,
98 .ammoPerSecond = 20.0f,
99 }, // EnergyGun
101 .fireCooldown = 0.4f,
102 .magazineSize = 1,
103 .defaultAmmoCapacity = 99,
104 .damage = 0.0f,
105 .hitscan = false,
106 .initialProjectileSpeed = 1500.0f, // overridden by GrenadeConfig.throwSpeed at spawn
107 .explosive = false,
108 }, // HEGrenade
110 .fireCooldown = 0.4f,
111 .magazineSize = 1,
112 .defaultAmmoCapacity = 99,
113 .damage = 0.0f,
114 .hitscan = false,
115 .initialProjectileSpeed = 1200.0f,
116 .explosive = false,
117 }, // Molotov
119 .fireCooldown = 0.4f,
120 .magazineSize = 1,
121 .defaultAmmoCapacity = 99,
122 .damage = 0.0f,
123 .hitscan = false,
124 .initialProjectileSpeed = 1500.0f,
125 .explosive = false,
126 }, // Impulse
127 }};
128
129 return k_kWeaponConfigs[static_cast<std::size_t>(type)];
130}
131
134{
135 static constexpr std::array<ProjectileConfig, 7> k_kProjectileConfigs{{
136 ProjectileConfig{}, // Rifle
138 .modelId = 1,
139 .initialSpeed = 0.0f,
140 .scale = 1.0f,
141 .shape = CollisionShape{.halfExtents = {5.0f, 5.0f, 5.0f}},
142 .maxLifeTime = 5.0f,
143 .explosionRadius = 250.0f,
144 .explosionFalloffExponent = 3.0f, // Cubic: direct hits 1-shot, ~2m away ≈ 65 dmg, ~3m ≈ chip.
145 .selfDamageMultiplier = 0.4f, // 40% self-damage so rocket jumps don't suicide.
146 .maxKnockback = 800.0f, // Feet-rocket pop scaled against k_jumpSpeed=660; retune if too soft.
147 .knockbackFalloffExponent = 2.0f, // Quadratic: push reaches further than damage.
148 }, // Rocket
149 ProjectileConfig{}, // RailGun
150 ProjectileConfig{}, // EnergyGun
151 ProjectileConfig{}, // HEGrenade — flight params come from GrenadeConfig
152 ProjectileConfig{}, // Molotov
153 ProjectileConfig{}, // Impulse
154 }};
155
156 return k_kProjectileConfigs[static_cast<std::size_t>(type)];
157}
Collision shape component — AABB or vertical capsule.
Projectile component and weapon/surface type enumerations.
const ProjectileConfig & getProjectileConfig(WeaponType type)
Returns the projectile config for a weapon type.
Definition WeaponConfig.hpp:133
const WeaponConfig & getWeaponConfig(WeaponType type)
Returns the gameplay config for a weapon type.
Definition WeaponConfig.hpp:55
WeaponType
Weapon type — determines tracer style, damage, sound, and impact effects.
Definition WeaponState.hpp:12
Collision shape attached to an entity.
Definition CollisionShape.hpp:34
Definition WeaponConfig.hpp:31
float maxKnockback
Peak knockback velocity (u/s) imparted at the epicenter.
Definition WeaponConfig.hpp:47
float selfDamageMultiplier
Damage scale applied when the rocket's owner is the victim (self-damage).
Definition WeaponConfig.hpp:44
int modelId
Definition WeaponConfig.hpp:32
float explosionFalloffExponent
Damage falloff curve exponent.
Definition WeaponConfig.hpp:41
float explosionRadius
Definition WeaponConfig.hpp:37
float initialSpeed
Definition WeaponConfig.hpp:33
float maxLifeTime
Definition WeaponConfig.hpp:36
CollisionShape shape
Definition WeaponConfig.hpp:35
float knockbackFalloffExponent
Knockback falloff exponent (same form as explosionFalloffExponent).
Definition WeaponConfig.hpp:51
float scale
Definition WeaponConfig.hpp:34
Immutable gameplay stats for a weapon type.
Definition WeaponConfig.hpp:14
int defaultAmmoCapacity
Definition WeaponConfig.hpp:17
float maxChargeTime
in seconds
Definition WeaponConfig.hpp:27
bool isCharge
True for charge weapons (hold to charge, release to fire).
Definition WeaponConfig.hpp:23
bool hitscan
Definition WeaponConfig.hpp:19
float ammoPerSecond
Ammo drain rate (beam weapons only).
Definition WeaponConfig.hpp:25
float initialProjectileSpeed
Definition WeaponConfig.hpp:20
float chargeDamage
Damage dealt on release (charge weapons only).
Definition WeaponConfig.hpp:26
int magazineSize
Definition WeaponConfig.hpp:16
bool isBeam
True for continuous beam weapons (no per-shot cooldown).
Definition WeaponConfig.hpp:22
float fireCooldown
Definition WeaponConfig.hpp:15
bool explosive
Definition WeaponConfig.hpp:21
float damage
Definition WeaponConfig.hpp:18
float dps
Damage per second (beam weapons only; discrete weapons use damage).
Definition WeaponConfig.hpp:24