FBC: NIGHT SHIFT - added tiered Blender service weapon rounds, a barrel spawn and an agent visor fix
This commit is contained in:
parent
b9051e8f96
commit
893ea48a95
20 changed files with 375 additions and 34 deletions
Binary file not shown.
BIN
assets/blender/fbc_projectile.blend
Normal file
BIN
assets/blender/fbc_projectile.blend
Normal file
Binary file not shown.
Binary file not shown.
BIN
assets/models/muzzle_flash.glb
Normal file
BIN
assets/models/muzzle_flash.glb
Normal file
Binary file not shown.
BIN
assets/models/projectile_1.glb
Normal file
BIN
assets/models/projectile_1.glb
Normal file
Binary file not shown.
BIN
assets/models/projectile_2.glb
Normal file
BIN
assets/models/projectile_2.glb
Normal file
Binary file not shown.
BIN
assets/models/projectile_3.glb
Normal file
BIN
assets/models/projectile_3.glb
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1 MiB After Width: | Height: | Size: 1 MiB |
|
|
@ -7,6 +7,7 @@
|
|||
enum class EventType {
|
||||
EnemyHit,
|
||||
EnemyKilled,
|
||||
WeaponFired,
|
||||
AreaDetonation,
|
||||
PlayerDamaged,
|
||||
ShardCollected,
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ void player_update(Player& player, const InputState& in, float dt, const Floor&
|
|||
player.mods.taken -= dt;
|
||||
if (player.mods.taken < 0.0f) player.mods.taken = 0.0f;
|
||||
|
||||
player.aim_hold -= dt;
|
||||
Vec2 dir{in.move_x, in.move_y};
|
||||
if (length_sq(dir) > 1.0f) dir = normalized(dir);
|
||||
if (player.aim_hold <= 0.0f && length_sq(dir) > 1e-4f) player.facing = dir;
|
||||
|
||||
const float speed_mult = player.dash_timer > 0.0f ? kDashSpeedMult : 1.0f;
|
||||
player.pos += dir * (player.stats.move_speed * player.mods.speed_mult * speed_mult * dt);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ struct PlayerStats {
|
|||
|
||||
struct Player {
|
||||
Vec2 pos{};
|
||||
Vec2 facing{0.0f, 1.0f}; // where the Service Weapon currently points
|
||||
float aim_hold = 0.0f; // keep the shot direction while this is positive
|
||||
float hp = 100.0f;
|
||||
PlayerStats stats{};
|
||||
std::array<int, static_cast<int>(Directive::Count)> directives{};
|
||||
|
|
|
|||
|
|
@ -10,27 +10,29 @@
|
|||
namespace {
|
||||
|
||||
constexpr float kMaxEnemyRadius = 1.3f; // for broad-phase query radii
|
||||
constexpr float kMuzzleForward = 0.92f; // agent-local +Z, past the chest
|
||||
constexpr float kMuzzleSide = -0.32f; // the rifle sits on the agent's left
|
||||
|
||||
const WeaponDef kDefs[kWeaponTypeCount] = {
|
||||
{WeaponType::Spin, "SPIN",
|
||||
"Service Weapon: rapid auto projectiles at the nearest target",
|
||||
12.0f, 0.55f, 26.0f, 1, 0.0f, 0.0f, 0.0f, 1.6f, 0.35f,
|
||||
"Service Weapon: rapid resonant rounds at the nearest target",
|
||||
14.0f, 0.55f, 42.0f, 1, 0.0f, 0.0f, 0.0f, 1.6f, 0.35f,
|
||||
Directive::PiercingRounds, "SPIN - CORRIDOR"},
|
||||
{WeaponType::Shatter, "SHATTER",
|
||||
"shotgun cone that shreds whatever is closest",
|
||||
6.0f, 1.6f, 22.0f, 5, 50.0f, 0.0f, 0.0f, 0.40f, 0.30f,
|
||||
6.0f, 1.6f, 34.0f, 5, 50.0f, 0.0f, 0.0f, 0.40f, 0.30f,
|
||||
Directive::BlackRockPlating, "SHATTER - QUARRY"},
|
||||
{WeaponType::Charge, "CHARGE",
|
||||
"slow homing nuke aimed at the densest cluster",
|
||||
42.0f, 4.0f, 13.0f, 1, 0.0f, 2.2f, 2.2f, 4.0f, 0.80f,
|
||||
42.0f, 4.0f, 20.0f, 1, 0.0f, 2.2f, 2.2f, 4.0f, 0.80f,
|
||||
Directive::BoardFavor, "CHARGE - DIRECTIVE"},
|
||||
{WeaponType::Launch, "LAUNCH",
|
||||
"telekinetic debris pelts random targets",
|
||||
18.0f, 1.1f, 30.0f, 1, 0.0f, 5.0f, 0.0f, 1.2f, 0.30f,
|
||||
18.0f, 1.1f, 44.0f, 1, 0.0f, 5.0f, 0.0f, 1.2f, 0.30f,
|
||||
Directive::LaunchTraining, "LAUNCH - MASS DRIVER"},
|
||||
{WeaponType::Projector, "PROJECTOR",
|
||||
"briefing reel: slow homing projections that burst on impact",
|
||||
26.0f, 3.0f, 16.0f, 1, 0.0f, 1.8f, 3.0f, 3.2f, 0.65f,
|
||||
26.0f, 3.0f, 26.0f, 1, 0.0f, 1.8f, 3.0f, 3.2f, 0.65f,
|
||||
Directive::ResonanceAttunement, "PROJECTOR - BRIEFING REEL"},
|
||||
};
|
||||
|
||||
|
|
@ -86,6 +88,22 @@ void fire_spread(Projectile proto, Vec2 dir, int pellets, float spread_deg,
|
|||
|
||||
} // namespace
|
||||
|
||||
Vec2 muzzle_pos(const Player& player) {
|
||||
const Vec2 f = length_sq(player.facing) > 1e-6f
|
||||
? normalized(player.facing) : Vec2{0.0f, 1.0f};
|
||||
const Vec2 right{f.y, -f.x};
|
||||
return player.pos + f * kMuzzleForward + right * kMuzzleSide;
|
||||
}
|
||||
|
||||
Vec2 aim_at(Player& player, Vec2 target) {
|
||||
const Vec2 dir = normalized(target - player.pos);
|
||||
if (length_sq(dir) > 1e-6f) {
|
||||
player.facing = dir;
|
||||
player.aim_hold = 0.6f;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
const WeaponDef& weapon_def(WeaponType type) {
|
||||
return kDefs[static_cast<int>(type)];
|
||||
}
|
||||
|
|
@ -96,7 +114,7 @@ void WeaponSystem::reset() {
|
|||
weapons.push_back({WeaponType::Spin, 1, false, 0.0f}); // the Service Weapon
|
||||
}
|
||||
|
||||
void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
||||
void WeaponSystem::update(float dt, Player& player, EnemySystem& enemies,
|
||||
EventQueue& events, Rng& rng, const Floor& floor) {
|
||||
// Broad phase over the horde, rebuilt once per tick.
|
||||
SpatialHash hash(2.0f);
|
||||
|
|
@ -112,18 +130,22 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
|||
if (w.cooldown_left > 0.0f || !player.alive()) continue;
|
||||
|
||||
const WeaponDef& def = weapon_def(w.type);
|
||||
const int tier = (w.evolved || w.level >= 4) ? 2
|
||||
: (w.level >= 2 ? 1 : 0);
|
||||
const float speed = def.projectile_speed * (1.0f + 0.16f * tier);
|
||||
const float dmg = def.damage * level_damage(w.level)
|
||||
* (1.0f + 0.10f * tier)
|
||||
* (w.evolved ? 1.35f : 1.0f) * player.stats.damage_mult;
|
||||
const float cd = def.cooldown * level_cooldown(w.level)
|
||||
/ std::max(0.25f, player.stats.fire_rate_mult);
|
||||
|
||||
Projectile proto;
|
||||
proto.pos = player.pos;
|
||||
proto.damage = dmg;
|
||||
proto.radius = def.projectile_radius;
|
||||
proto.life = def.projectile_life;
|
||||
proto.homing = def.homing;
|
||||
proto.source = w.type;
|
||||
proto.tier = tier;
|
||||
proto.evolved = w.evolved;
|
||||
proto.pierce = player.stats.pierce;
|
||||
|
||||
|
|
@ -132,7 +154,9 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
|||
case WeaponType::Spin: {
|
||||
const Enemy* target = nearest_enemy(enemies, player.pos, 1e6f);
|
||||
if (target == nullptr) break;
|
||||
proto.vel = normalized(target->pos - player.pos) * def.projectile_speed;
|
||||
aim_at(player, target->pos);
|
||||
proto.pos = muzzle_pos(player);
|
||||
proto.vel = normalized(target->pos - proto.pos) * speed;
|
||||
if (w.evolved) proto.pierce += 1; // Altered Form: Corridor
|
||||
projectiles.add(proto);
|
||||
fired = true;
|
||||
|
|
@ -141,10 +165,12 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
|||
case WeaponType::Shatter: {
|
||||
const Enemy* target = nearest_enemy(enemies, player.pos, 16.0f);
|
||||
if (target == nullptr) break;
|
||||
aim_at(player, target->pos);
|
||||
proto.pos = muzzle_pos(player);
|
||||
const int pellets = w.evolved ? 8 : def.pellets; // Altered Form: Quarry
|
||||
const float spread = w.evolved ? 70.0f : def.spread_deg;
|
||||
fire_spread(proto, target->pos - player.pos, pellets, spread,
|
||||
def.projectile_speed, projectiles);
|
||||
fire_spread(proto, target->pos - proto.pos, pellets, spread,
|
||||
speed, projectiles);
|
||||
fired = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -152,7 +178,9 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
|||
const Enemy* target = densest_cluster(enemies, hash);
|
||||
if (target == nullptr) target = nearest_enemy(enemies, player.pos, 1e6f);
|
||||
if (target == nullptr) break;
|
||||
proto.vel = normalized(target->pos - player.pos) * def.projectile_speed;
|
||||
aim_at(player, target->pos);
|
||||
proto.pos = muzzle_pos(player);
|
||||
proto.vel = normalized(target->pos - proto.pos) * speed;
|
||||
proto.aoe_radius = def.aoe_radius * (w.evolved ? 1.6f : 1.0f); // Directive
|
||||
projectiles.add(proto);
|
||||
fired = true;
|
||||
|
|
@ -164,15 +192,21 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies,
|
|||
if (enemies.enemies.empty()) break;
|
||||
const int id = rng.range_int(0, static_cast<int>(enemies.enemies.size()) - 1);
|
||||
const Enemy& target = enemies.enemies[static_cast<std::size_t>(id)];
|
||||
proto.pos = player.pos + Vec2{rng.range(-1.0f, 1.0f), rng.range(-1.0f, 1.0f)};
|
||||
proto.vel = normalized(target.pos - proto.pos) * def.projectile_speed;
|
||||
aim_at(player, target.pos);
|
||||
proto.pos = muzzle_pos(player)
|
||||
+ Vec2{rng.range(-0.35f, 0.35f), rng.range(-0.35f, 0.35f)};
|
||||
proto.vel = normalized(target.pos - proto.pos) * speed;
|
||||
projectiles.add(proto);
|
||||
}
|
||||
fired = shots > 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fired) w.cooldown_left = cd;
|
||||
if (fired) {
|
||||
w.cooldown_left = cd;
|
||||
events.push(EventType::WeaponFired, muzzle_pos(player),
|
||||
static_cast<float>(tier));
|
||||
}
|
||||
}
|
||||
|
||||
// --- Projectile flight + collision ---
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ struct WeaponDef {
|
|||
|
||||
const WeaponDef& weapon_def(WeaponType type);
|
||||
|
||||
// Muzzle of the Service Weapon in agent-local metres (see build_agent.py).
|
||||
constexpr float kMuzzleHeight = 1.17f;
|
||||
Vec2 muzzle_pos(const Player& player);
|
||||
|
||||
struct Projectile {
|
||||
Vec2 pos{};
|
||||
Vec2 vel{};
|
||||
|
|
@ -42,6 +46,7 @@ struct Projectile {
|
|||
float homing = 0.0f;
|
||||
float aoe_radius = 0.0f;
|
||||
int pierce = 0;
|
||||
int tier = 0; // visual/power upgrade: 0 standard, 1 tuned, 2 overcharged
|
||||
WeaponType source = WeaponType::Spin;
|
||||
bool evolved = false;
|
||||
bool alive = true;
|
||||
|
|
@ -59,6 +64,6 @@ struct WeaponSystem {
|
|||
DensePool<Projectile> projectiles{1024};
|
||||
|
||||
void reset();
|
||||
void update(float dt, const Player& player, EnemySystem& enemies,
|
||||
void update(float dt, Player& player, EnemySystem& enemies,
|
||||
EventQueue& events, Rng& rng, const class Floor& floor);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ struct Rig {
|
|||
case ActorModel::HissGhost: return {0.60f, 1.35f, 0.22f, 0.36f, 0.9f, 1.0f};
|
||||
case ActorModel::MoldSpore: return {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 2.0f};
|
||||
case ActorModel::Shard: return {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 3.0f};
|
||||
case ActorModel::RoundBasic:
|
||||
case ActorModel::RoundTuned:
|
||||
case ActorModel::RoundOvercharge:
|
||||
return {0.0f, 0.0f, 0.0f, 0.0f, 0.7f, 3.0f};
|
||||
default: return {};
|
||||
}
|
||||
}
|
||||
|
|
@ -227,7 +231,10 @@ void ModelBank::draw(ActorModel id, Vector3 pos, float yaw, float scale,
|
|||
SetShaderValue(shader_, loc_stagger_, &stagger, SHADER_UNIFORM_FLOAT);
|
||||
if (loc_phase_ >= 0)
|
||||
SetShaderValue(shader_, loc_phase_, &phase, SHADER_UNIFORM_FLOAT);
|
||||
const float glow = id == ActorModel::Shard ? 0.9f : 0.0f;
|
||||
const bool resonant_round = id >= ActorModel::RoundBasic
|
||||
&& id <= ActorModel::RoundOvercharge;
|
||||
const float glow = id == ActorModel::Shard ? 0.9f
|
||||
: (resonant_round ? 1.15f : 0.0f);
|
||||
if (loc_glow_ >= 0) SetShaderValue(shader_, loc_glow_, &glow, SHADER_UNIFORM_FLOAT);
|
||||
const float model_hiss = hiss_for(id);
|
||||
const float hiss_value = hiss > model_hiss ? hiss : model_hiss;
|
||||
|
|
@ -367,6 +374,10 @@ float ModelBank::height(ActorModel id) {
|
|||
case ActorModel::GarbageCan: return 0.72f;
|
||||
case ActorModel::DocumentStack: return 0.06f;
|
||||
case ActorModel::LooseSheet: return 0.02f;
|
||||
case ActorModel::RoundBasic: return 0.4f;
|
||||
case ActorModel::RoundTuned: return 0.5f;
|
||||
case ActorModel::RoundOvercharge: return 0.6f;
|
||||
case ActorModel::MuzzleFlash: return 0.6f;
|
||||
default: return 1.0f;
|
||||
}
|
||||
}
|
||||
|
|
@ -398,6 +409,10 @@ const char* ModelBank::file_name(ActorModel id) {
|
|||
case ActorModel::GarbageCan: return "assets/models/props/garbage_can.glb";
|
||||
case ActorModel::DocumentStack: return "assets/models/props/document_stack.glb";
|
||||
case ActorModel::LooseSheet: return "assets/models/props/loose_sheet.glb";
|
||||
case ActorModel::RoundBasic: return "assets/models/projectile_1.glb";
|
||||
case ActorModel::RoundTuned: return "assets/models/projectile_2.glb";
|
||||
case ActorModel::RoundOvercharge: return "assets/models/projectile_3.glb";
|
||||
case ActorModel::MuzzleFlash: return "assets/models/muzzle_flash.glb";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -480,6 +495,15 @@ void ModelBank::draw_fallback(ActorModel id, Vector3 pos, float yaw,
|
|||
DrawCube({0.0f, 0.01f * scale, 0.0f}, 0.40f * scale,
|
||||
0.012f * scale, 0.30f * scale, tint);
|
||||
break;
|
||||
case ActorModel::RoundBasic:
|
||||
case ActorModel::RoundTuned:
|
||||
case ActorModel::RoundOvercharge:
|
||||
DrawCylinder({0.0f, 0.0f, -0.3f * scale}, 0.08f * scale,
|
||||
0.16f * scale, 0.6f * scale, 6, tint);
|
||||
break;
|
||||
case ActorModel::MuzzleFlash:
|
||||
DrawSphere({0.0f, 0.0f, 0.0f}, 0.22f * scale, tint);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ enum class ActorModel {
|
|||
Hotline, TV, Pedestal, Duck, Cabinet, Crate, Debris, Switch,
|
||||
OfficeDesk, MeetingTable, OfficeChair, Computer, Plant, Sofa, FloorLamp,
|
||||
Partition, GarbageCan, DocumentStack, LooseSheet,
|
||||
RoundBasic, RoundTuned, RoundOvercharge, MuzzleFlash,
|
||||
Count
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "render/presenter.hpp"
|
||||
|
||||
#include "game/floor.hpp"
|
||||
#include "game/weapons.hpp"
|
||||
#include "render/layout.hpp"
|
||||
#include "render/profiler.hpp"
|
||||
#include "raymath.h"
|
||||
|
|
@ -18,7 +19,9 @@
|
|||
|
||||
namespace {
|
||||
|
||||
Color projectile_color(WeaponType type) {
|
||||
Color projectile_color(WeaponType type, int tier) {
|
||||
if (tier >= 2) return Color{255, 96, 64, 255};
|
||||
if (tier == 1) return Color{255, 224, 132, 255};
|
||||
switch (type) {
|
||||
case WeaponType::Spin: return Color{255, 240, 180, 255};
|
||||
case WeaponType::Shatter: return Color{255, 170, 90, 255};
|
||||
|
|
@ -475,6 +478,9 @@ void Presenter::reset() {
|
|||
player_walk_ = 0.0f;
|
||||
dash_pose_ = 0.0f;
|
||||
dash_prev_ = 0.0f;
|
||||
fire_pose_ = 0.0f;
|
||||
muzzle_flash_ = 0.0f;
|
||||
trails_.clear();
|
||||
player_running_ = false;
|
||||
}
|
||||
|
||||
|
|
@ -1088,6 +1094,19 @@ void Presenter::draw_scene(Game& game) {
|
|||
} else if (e.type == EventType::EnemyKilled) {
|
||||
shake_ = std::max(shake_, 0.10f);
|
||||
spawn_sparks(e.pos, 0.9f, Color{255, 60, 50, 255}, 8, 3.4f);
|
||||
} else if (e.type == EventType::WeaponFired) {
|
||||
const Vec2 aim = e.pos - game.player.pos;
|
||||
const int tier = static_cast<int>(e.magnitude);
|
||||
muzzle_flash_ = 0.09f;
|
||||
muzzle_flash_pos_ = {e.pos.x, kMuzzleHeight, e.pos.y};
|
||||
muzzle_flash_yaw_ = std::atan2(aim.x, aim.y);
|
||||
muzzle_flash_tier_ = tier;
|
||||
fire_pose_ = 0.20f;
|
||||
shake_ = std::max(shake_, 0.015f + 0.015f * e.magnitude);
|
||||
spawn_sparks(e.pos, kMuzzleHeight,
|
||||
tier >= 2 ? Color{255, 110, 60, 235}
|
||||
: Color{255, 220, 150, 235},
|
||||
2 + tier, 1.8f);
|
||||
} else if (e.type == EventType::AreaDetonation) {
|
||||
const float radius = std::max(1.0f, e.magnitude);
|
||||
Vector3 origins[16];
|
||||
|
|
@ -1155,7 +1174,14 @@ void Presenter::draw_scene(Game& game) {
|
|||
}
|
||||
sparks_.erase(std::remove_if(sparks_.begin(), sparks_.end(),
|
||||
[](const Spark& s) { return s.age > s.life; }),
|
||||
sparks_.end());
|
||||
sparks_.end());
|
||||
fire_pose_ = std::max(0.0f, fire_pose_ - frame_dt);
|
||||
muzzle_flash_ = std::max(0.0f, muzzle_flash_ - frame_dt);
|
||||
trail_clock_ -= frame_dt;
|
||||
for (RoundTrail& tr : trails_) tr.age += frame_dt;
|
||||
trails_.erase(std::remove_if(trails_.begin(), trails_.end(),
|
||||
[](const RoundTrail& tr) { return tr.age > tr.life; }),
|
||||
trails_.end());
|
||||
debris_.update(frame_dt, game.corruption.value());
|
||||
concrete_debris_.update(frame_dt);
|
||||
|
||||
|
|
@ -1229,10 +1255,15 @@ void Presenter::draw_scene(Game& game) {
|
|||
aura_.draw_ground_waves();
|
||||
rlEnableDepthMask();
|
||||
|
||||
// Player: derive facing from motion (presentation-only, no sim change).
|
||||
// Player: the sim owns facing (aim direction while firing, motion otherwise).
|
||||
const Vec2 moved = p - last_player_pos_;
|
||||
if (length_sq(moved) > 1e-5f) player_yaw_ = std::atan2(moved.x, moved.y);
|
||||
last_player_pos_ = p;
|
||||
const float aim_yaw = std::atan2(game.player.facing.x,
|
||||
game.player.facing.y);
|
||||
const float delta = std::atan2(std::sin(aim_yaw - player_yaw_),
|
||||
std::cos(aim_yaw - player_yaw_));
|
||||
const float turn = game.player.aim_hold > 0.0f ? 22.0f : 7.0f;
|
||||
player_yaw_ += delta * std::min(1.0f, frame_dt * turn);
|
||||
|
||||
// Speed from distance / time rather than raw per-frame delta: stable
|
||||
// when the fixed-step sim runs zero or several ticks in one render.
|
||||
|
|
@ -1259,8 +1290,9 @@ void Presenter::draw_scene(Game& game) {
|
|||
// double up on top of the skeletal Run/Idle clips.
|
||||
const char* agent_clip = "Idle";
|
||||
if (dash_pose_ > 0.0f) agent_clip = "Dash";
|
||||
else if (fire_pose_ > 0.0f) agent_clip = "Fire";
|
||||
else if (player_running_) agent_clip = "Run";
|
||||
models_.update_animation(ActorModel::Guard, agent_clip, frame_dt, 0.16f);
|
||||
models_.update_animation(ActorModel::Guard, agent_clip, frame_dt, 0.12f);
|
||||
// A hit used to swap in the Stagger clip, whose legs are locked at rest —
|
||||
// the walk stopped dead. Keep locomotion and flinch the upper body only.
|
||||
models_.flinch(ActorModel::Guard, player_flash * 0.9f);
|
||||
|
|
@ -1313,13 +1345,51 @@ void Presenter::draw_scene(Game& game) {
|
|||
world_object_color(obj));
|
||||
}
|
||||
|
||||
// Projectile glow remains camera-facing — it is an FX, not a card.
|
||||
for (const RoundTrail& tr : trails_) {
|
||||
if (!cull.visible(tr.pos.x, tr.pos.y, tr.pos.z, tr.size)) continue;
|
||||
const float fade = 1.0f - tr.age / tr.life;
|
||||
Color tint = tr.color;
|
||||
tint.a = static_cast<unsigned char>(190.0f * fade * fade);
|
||||
const float size = tr.size * (0.35f + 0.65f * fade);
|
||||
glow_batch.add_billboard(tr.pos, size, size, cam_right, cam_up, tint);
|
||||
}
|
||||
|
||||
const bool emit_trail = trail_clock_ <= 0.0f;
|
||||
for (const Projectile& pr : game.weapon_system.projectiles) {
|
||||
if (!cull.visible(pr.pos.x, 1.1f, pr.pos.y, 0.8f)) continue;
|
||||
const float s = projectile_size(pr.source);
|
||||
glow_batch.add_billboard({pr.pos.x, 1.1f, pr.pos.y}, s, s,
|
||||
cam_right, cam_up,
|
||||
projectile_color(pr.source));
|
||||
const Vector3 round_pos{pr.pos.x, kMuzzleHeight, pr.pos.y};
|
||||
if (!cull.visible(round_pos.x, round_pos.y, round_pos.z, 1.4f)) continue;
|
||||
const float s = projectile_size(pr.source) * (1.0f + 0.22f * pr.tier);
|
||||
const ActorModel model = pr.tier >= 2 ? ActorModel::RoundOvercharge
|
||||
: pr.tier == 1 ? ActorModel::RoundTuned
|
||||
: ActorModel::RoundBasic;
|
||||
const float yaw = std::atan2(pr.vel.x, pr.vel.y);
|
||||
const float base_scale = pr.source == WeaponType::Charge ? 0.85f
|
||||
: pr.source == WeaponType::Projector ? 0.75f
|
||||
: 1.0f;
|
||||
models_.draw(model, round_pos, yaw,
|
||||
base_scale * (1.0f + 0.12f * pr.tier), WHITE,
|
||||
0.0f, false, 0.0f, 0.0f,
|
||||
anim_time_ * 7.0f + pr.pos.x, 0.0f);
|
||||
const float glow_size = s * (2.2f + 0.5f * pr.tier);
|
||||
glow_batch.add_billboard(round_pos, glow_size, glow_size, cam_right,
|
||||
cam_up, projectile_color(pr.source, pr.tier));
|
||||
if (emit_trail && trails_.size() < 220) {
|
||||
trails_.push_back({round_pos, projectile_color(pr.source, pr.tier),
|
||||
0.0f, 0.22f, s * 0.8f});
|
||||
}
|
||||
}
|
||||
if (emit_trail) trail_clock_ = 0.03f;
|
||||
|
||||
if (muzzle_flash_ > 0.0f) {
|
||||
const float k = muzzle_flash_ / 0.09f;
|
||||
const float scale = (0.60f + 0.18f * muzzle_flash_tier_)
|
||||
* (0.55f + 0.45f * k);
|
||||
models_.draw(ActorModel::MuzzleFlash, muzzle_flash_pos_,
|
||||
muzzle_flash_yaw_, scale, WHITE, 0.0f, false, 0.0f,
|
||||
0.0f, anim_time_ * 14.0f, 0.0f);
|
||||
const float flare = (0.85f + 0.25f * muzzle_flash_tier_) * k;
|
||||
glow_batch.add_billboard(muzzle_flash_pos_, flare, flare, cam_right,
|
||||
cam_up, Color{255, 228, 170, 210});
|
||||
}
|
||||
|
||||
// Light particles from hits, kills and tier-ups — camera-facing glows.
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ struct Spark {
|
|||
float size = 0.12f;
|
||||
};
|
||||
|
||||
struct RoundTrail {
|
||||
Vector3 pos{};
|
||||
Color color{};
|
||||
float age = 0.0f;
|
||||
float life = 0.22f;
|
||||
float size = 0.2f;
|
||||
};
|
||||
|
||||
class ViewCull;
|
||||
|
||||
class Presenter {
|
||||
|
|
@ -85,6 +93,12 @@ private:
|
|||
float player_walk_ = 0.0f; // smoothed locomotion weight for the agent clips
|
||||
float dash_pose_ = 0.0f; // presentation-only hold for the Dash pose
|
||||
float dash_prev_ = 0.0f; // previous dash timer, for rising-edge detection
|
||||
float fire_pose_ = 0.0f; // brief fire clip hold
|
||||
float muzzle_flash_ = 0.0f;
|
||||
float trail_clock_ = 0.0f;
|
||||
Vector3 muzzle_flash_pos_{};
|
||||
float muzzle_flash_yaw_ = 0.0f;
|
||||
int muzzle_flash_tier_ = 0;
|
||||
bool player_running_ = false; // hysteresis latch for Idle <-> Run
|
||||
bool hiss_test_ = false;
|
||||
bool floor_mode_ = false;
|
||||
|
|
@ -93,4 +107,5 @@ private:
|
|||
Vec2 last_player_pos_{};
|
||||
std::vector<DamageNumber> damage_numbers_;
|
||||
std::vector<Spark> sparks_;
|
||||
std::vector<RoundTrail> trails_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -144,16 +144,14 @@ def build_agent():
|
|||
0.92, P["leather"], shift=(side * 0.21, -0.245))
|
||||
K.plate(r, "belt_pouch_%d" % side, K.octagon(0.095, 0.07), 0.84, 0.97,
|
||||
0.95, P["leather"], shift=(side * 0.26, -0.18))
|
||||
K.plate(r, "patch", K.octagon(0.085, 0.085), 0.0, 0.012, 1.0,
|
||||
P["patch"], ao=0.0)
|
||||
patch = r.children[-1]
|
||||
patch = K.plate(r, "patch", K.octagon(0.085, 0.085), 0.0, 0.012, 1.0,
|
||||
P["patch"], ao=0.0)
|
||||
for v in patch.data.vertices:
|
||||
v.co = Euler((0, 0, math.pi / 2)).to_matrix() @ v.co + Vector(
|
||||
(0.42, -0.045, 1.43))
|
||||
patch.data.update()
|
||||
K.plate(r, "patch_mark", K.octagon(0.05, 0.05), 0.0, 0.014, 1.0,
|
||||
P["hiss_red"], ao=0.0)
|
||||
mark = r.children[-1]
|
||||
mark = K.plate(r, "patch_mark", K.octagon(0.05, 0.05), 0.0, 0.014, 1.0,
|
||||
P["hiss_red"], ao=0.0)
|
||||
for v in mark.data.vertices:
|
||||
v.co = Euler((0, 0, math.pi / 2)).to_matrix() @ v.co + Vector(
|
||||
(0.43, -0.055, 1.43))
|
||||
|
|
|
|||
189
tools/blender/build_projectile.py
Normal file
189
tools/blender/build_projectile.py
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
"""Build the Service Weapon's upgradable resonant rounds and muzzle flare.
|
||||
|
||||
Run inside Blender 5.x:
|
||||
exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_projectile.py").read())
|
||||
"""
|
||||
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
from mathutils import Euler
|
||||
|
||||
REPO = "/home/dandovlatov/Documents/cntrl"
|
||||
MODEL_DIR = os.path.join(REPO, "assets", "models")
|
||||
BLEND_DIR = os.path.join(REPO, "assets", "blender")
|
||||
CONCEPT_DIR = os.path.join(REPO, "docs", "concept")
|
||||
for d in (MODEL_DIR, BLEND_DIR, CONCEPT_DIR):
|
||||
os.makedirs(d, exist_ok=True)
|
||||
|
||||
sys.path.insert(0, os.path.join(REPO, "tools", "blender"))
|
||||
import importlib
|
||||
import actor_kit as K
|
||||
importlib.reload(K)
|
||||
|
||||
K.clear_scene()
|
||||
P = K.PALETTE
|
||||
P.update({
|
||||
"shell": "#20242a", "shell_dk": "#12151a", "metal": "#88929c",
|
||||
"amber": "#ffab24", "board_hot": "#fff2c2", "white": "#ffffff",
|
||||
"resonance": "#4ec9b0",
|
||||
})
|
||||
|
||||
TO_FORWARD = Euler((math.pi / 2, 0, 0)).to_matrix()
|
||||
|
||||
|
||||
def blade(root, name, s, angle, value):
|
||||
outline = [(-0.42 * s, 0.09 * s), (0.02 * s, 0.38 * s),
|
||||
(0.46 * s, 0.16 * s), (0.34 * s, 0.0), (-0.38 * s, 0.0)]
|
||||
obj = K.plate(root, name, outline, -0.018 * s, 0.018 * s, 0.82,
|
||||
value, ao=0.04)
|
||||
ca, sa = math.cos(angle), math.sin(angle)
|
||||
for v in obj.data.vertices:
|
||||
u, w, t = v.co.x, v.co.y, v.co.z
|
||||
v.co = (w * ca - t * sa, w * sa + t * ca, u)
|
||||
obj.data.update()
|
||||
return obj
|
||||
|
||||
|
||||
def face_forward(root):
|
||||
for obj in root.children:
|
||||
if obj.type != "MESH":
|
||||
continue
|
||||
for v in obj.data.vertices:
|
||||
v.co = TO_FORWARD @ v.co
|
||||
obj.data.update()
|
||||
|
||||
|
||||
def build_round(name, path, s, core, hot, accent, fin_count, rings, spikes):
|
||||
r = K.new_actor(name)
|
||||
K.loft(r, "shell", [
|
||||
{"z": -0.48 * s, "r": (0.035 * s, 0.035 * s), "n": 10},
|
||||
{"z": -0.30 * s, "r": (0.115 * s, 0.115 * s), "n": 10,
|
||||
"fold": (0.06, 5)},
|
||||
{"z": 0.02 * s, "r": (0.145 * s, 0.145 * s), "n": 10,
|
||||
"fold": (0.08, 6)},
|
||||
{"z": 0.34 * s, "r": (0.105 * s, 0.105 * s), "n": 10},
|
||||
{"z": 0.66 * s, "r": (0.022 * s, 0.022 * s), "n": 10},
|
||||
], P["shell"], ao=0.12)
|
||||
K.loft(r, "collar", [
|
||||
{"z": -0.22 * s, "r": (0.155 * s, 0.155 * s), "n": 8},
|
||||
{"z": -0.07 * s, "r": (0.175 * s, 0.175 * s), "n": 8},
|
||||
], P["metal"], ao=0.05)
|
||||
K.crystal(r, "energy_core", (0, 0, -0.10 * s), 0.52 * s, core,
|
||||
sides=6, seed=7, ao=0.0)
|
||||
K.crystal(r, "hot_tip", (0, 0, 0.40 * s), 0.26 * s, hot,
|
||||
sides=5, seed=13, ao=0.0)
|
||||
for i, rz in enumerate(rings):
|
||||
K.ring(r, "band_%d" % i, (0, 0, rz * s), 0.165 * s,
|
||||
0.020 * s, accent, segments=12)
|
||||
for i in range(fin_count):
|
||||
blade(r, "fin_%d" % i, s, 2.0 * math.pi * i / fin_count + 0.35,
|
||||
accent)
|
||||
for i in range(spikes):
|
||||
a = 2.0 * math.pi * (i + 0.5) / spikes
|
||||
K.crystal(r, "spike_%d" % i,
|
||||
(0.16 * s * math.cos(a), 0.16 * s * math.sin(a), -0.24 * s),
|
||||
0.30 * s, accent, sides=4, seed=20 + i,
|
||||
tilt=(math.radians(72) * math.sin(a),
|
||||
-math.radians(72) * math.cos(a), 0), ao=0.0)
|
||||
face_forward(r)
|
||||
mesh = K.merge_actor(r, name)
|
||||
tris = K.triangle_count(r)
|
||||
K.export_actor(r, name, path)
|
||||
print("[round] %-14s %4d tris %s" % (name, tris, path))
|
||||
return r, mesh, tris
|
||||
|
||||
|
||||
def build_flare(name, path):
|
||||
s = 1.0
|
||||
r = K.new_actor(name)
|
||||
K.blob(r, "flare_core", (0, 0, 0), (0.17, 0.17, 0.24), P["white"],
|
||||
subdiv=1, warp=0.0, ao=0.0)
|
||||
for i in range(8):
|
||||
a = 2.0 * math.pi * i / 8
|
||||
K.crystal(r, "ray_%d" % i, (0, 0, 0), 0.60 * s,
|
||||
P["board_hot"] if i % 2 == 0 else P["amber"],
|
||||
sides=4, seed=40 + i,
|
||||
tilt=(math.pi / 2, 0, a + math.pi / 2), ao=0.0)
|
||||
K.loft(r, "throat", [
|
||||
{"z": 0.0, "r": (0.13, 0.13), "n": 8},
|
||||
{"z": 0.34, "r": (0.20, 0.20), "n": 8, "fold": (0.10, 4)},
|
||||
{"z": 0.78, "r": (0.01, 0.01), "n": 8},
|
||||
], P["amber"], ao=0.0)
|
||||
face_forward(r)
|
||||
mesh = K.merge_actor(r, name)
|
||||
tris = K.triangle_count(r)
|
||||
K.export_actor(r, name, path)
|
||||
print("[flare] %-14s %4d tris %s" % (name, tris, path))
|
||||
return r, mesh, tris
|
||||
|
||||
|
||||
built = []
|
||||
for spec in (
|
||||
("projectile_1", 0.90, P["amber"], P["board_hot"], P["board"],
|
||||
3, (0.10,), 0),
|
||||
("projectile_2", 1.10, P["board"], P["white"], P["resonance"],
|
||||
4, (-0.04, 0.22), 0),
|
||||
("projectile_3", 1.35, P["hiss_hot"], P["board_hot"], P["board"],
|
||||
6, (-0.14, 0.08, 0.28), 6),
|
||||
):
|
||||
root, mesh, tris = build_round(
|
||||
spec[0], os.path.join(MODEL_DIR, spec[0] + ".glb"), *spec[1:])
|
||||
assert tris < 1400, "%s over triangle budget" % root.name
|
||||
built.append((root, mesh))
|
||||
|
||||
flare_root, flare_mesh, flare_tris = build_flare(
|
||||
"muzzle_flash", os.path.join(MODEL_DIR, "muzzle_flash.glb"))
|
||||
assert flare_tris < 800, "muzzle_flash over triangle budget"
|
||||
built.append((flare_root, flare_mesh))
|
||||
|
||||
for i, (root, _) in enumerate(built):
|
||||
root.location = ((i - 1.5) * 1.7, 0.0, 0.0)
|
||||
for child in root.children:
|
||||
child.location = (0, 0, 0)
|
||||
|
||||
world = bpy.data.worlds.new("ProjectileWorld")
|
||||
bpy.context.scene.world = world
|
||||
world.use_nodes = True
|
||||
bg = next(n for n in world.node_tree.nodes if n.type == "BACKGROUND")
|
||||
bg.inputs["Color"].default_value = (*K.rgb("#0e1418"), 1.0)
|
||||
bg.inputs["Strength"].default_value = 0.7
|
||||
|
||||
for name, loc, power, col in (
|
||||
("Key", (-3, -6, 5), 1800, "#e8f0e2"),
|
||||
("Rim", (3, 5, 4), 1200, "#4ec9b0"),
|
||||
("Fill", (0, -3, 2), 600, "#ff8a1f"),
|
||||
):
|
||||
data = bpy.data.lights.new(name, "AREA")
|
||||
data.energy = power
|
||||
data.shape = "DISK"
|
||||
data.size = 5
|
||||
data.color = K.rgb(col)
|
||||
obj = bpy.data.objects.new(name, data)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
obj.location = loc
|
||||
obj.rotation_euler = (K.Vector((0, 0, 0.5)) - K.Vector(loc)).to_track_quat(
|
||||
"-Z", "Y").to_euler()
|
||||
|
||||
cam_data = bpy.data.cameras.new("ProjectileCam")
|
||||
cam = bpy.data.objects.new("ProjectileCam", cam_data)
|
||||
bpy.context.scene.collection.objects.link(cam)
|
||||
cam.location = (0.0, -7.0, 2.6)
|
||||
cam.rotation_euler = (K.Vector((0, 0, 0.45)) - cam.location).to_track_quat(
|
||||
"-Z", "Y").to_euler()
|
||||
cam_data.lens = 48
|
||||
bpy.context.scene.camera = cam
|
||||
|
||||
scene = bpy.context.scene
|
||||
engines = [i.identifier for i in bpy.types.RenderSettings.bl_rna.properties[
|
||||
"engine"].enum_items]
|
||||
scene.render.engine = ("BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in engines
|
||||
else engines[0])
|
||||
scene.render.resolution_x = 1100
|
||||
scene.render.resolution_y = 700
|
||||
scene.render.image_settings.file_format = "PNG"
|
||||
scene.render.filepath = os.path.join(CONCEPT_DIR, "projectile_reference.png")
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(BLEND_DIR, "fbc_projectile.blend"))
|
||||
print("[done] projectile rounds + flare built, exported and saved")
|
||||
Loading…
Add table
Reference in a new issue