Sci-Fi Expansion Pack
Orbital laser
A shoulder module that calls a deep-red beam down from orbit: 10 seconds of warning, then 12 seconds of beam that destroys whatever stands inside it – and the effect has to be visible kilometres away, far outside the walker's streaming range.

Sequence
| Phase | Duration | What happens |
|---|---|---|
| TARGET SET | until fired | map circle menu (point, track, or START + END for a sweep) or the mark key; nothing happens yet |
| FIRE | – | salvo key, the same key that fires the rockets |
| WARN | 10 s | red light pillar and a 40 m ring at the target, rising sound – for every player |
| DESCENT | 1.2 s | the beam comes down from 2.5 km; no damage yet |
| BEAM | 12 s | damage, heat zone, burning path; follows a vehicle, the steering player or the sweep A → B |
| COOLDOWN | 3 min | one charge per mounted module, refilled at a depot |
Set the target, fire with the salvo key
Players already know how the rockets work: mark targets, then fire. The laser uses the same rhythm. The map menu
and the mark key only store a target on the server; the salvo key fires it. The stored target lives in
[RplProp] fields on the module manager, so the map and the HUD of the whole crew can show it.
// add-on: module manager (modded class), server side
[RplProp()] protected bool m_bPlanned;
[RplProp()] protected vector m_vPlanA; // target or sweep start
[RplProp()] protected vector m_vPlanB; // sweep end
[RplProp()] protected bool m_bPlanSweep;
string ServerSetTarget(vector a, bool sweep, vector b)
{
string error = CheckRange(a, sweep, b); // 80 m .. 4 km, sweep <= 400 m, not across the own walker
if (!error.IsEmpty())
return error; // sent back to the player as a hint
m_bPlanned = true;
m_vPlanA = a;
m_vPlanB = b;
m_bPlanSweep = sweep;
Replication.BumpMe();
return "";
}
The salvo key belongs to the base mod. The add-on mods its input component: when a laser target is set, it sends its own request first and only falls through to the rockets if rocket targets are marked as well.
modded class MyWalker_CrewInput
{
override protected void OnFireSalvo(float value, EActionTrigger reason)
{
MyWalker_Modules mods = MyWalker_Modules.FindOn(GetOwner().GetRootParent());
if (mods && mods.HasLaserTarget())
{
MyPlayerController.Local().RequestFireLaser(GetOwner().GetRootParent());
if (!HasRocketTargets())
return; // no "no target set" hint from the rockets
}
super.OnFireSalvo(value, reason);
}
}
Effects for everyone, not for the walker's neighbours
Replicated state on the walker only reaches clients that stream the walker. The target can be 4 km away, and players standing next to it may not stream the walker at all. So the server sends each phase to every player controller (the same path the base mod uses for explosions), and each machine with a display builds the effect from that message. The dedicated server draws nothing.
//! [Server] One message to all players. START / SWEEP / BEAM / END reliable, MOVE unreliable (10 Hz).
static void Broadcast(int msg, int strikeId, vector a, vector b)
{
array<int> players = {};
GetGame().GetPlayerManager().GetPlayers(players);
foreach (int id : players)
{
MyPlayerController pc = MyPlayerController.Cast(GetGame().GetPlayerManager().GetPlayerController(id));
if (pc)
pc.SendLaserFx(msg, strikeId, a, b); // local host: handled directly, others: Rpc to the owner
}
}
A sweep from A to B is not sent position by position. Every client knows A, B and the start time and computes the beam position itself – the fire and the scorch marks run exactly with the beam, without network delay.
A 2.5 km beam that does not disappear
The beam is therefore built from 25 pieces of 100 m, each with its own bounds. That alone makes it visible up to the
object view distance. To see it even further, the whole column is drawn as a scaled-down copy closer to the camera:
every point X becomes C + (X - C) * k. Seen from the camera C the projection is exactly the same, but the
copy is close enough to be drawn.
//! Place one column of segments; beyond NEAR_LIMIT the column is scaled towards the camera.
void PlaceColumn(array<IEntity> segs, vector foot, float height, float width)
{
vector cam[4];
GetGame().GetWorld().GetCurrentCamera(cam);
vector c = cam[3];
float far = Math.Max(vector.Distance(c, foot), vector.Distance(c, foot + Vector(0, height, 0)));
float k = 1.0;
if (far > NEAR_LIMIT) // 600 m
k = NEAR_LIMIT / far;
width = Math.Max(width, vector.Distance(c, foot) * MIN_ANGLE); // stays a few pixels wide far away
for (int i = 0; i < segs.Count(); i++)
{
vector real = foot + Vector(0, i * SEG_LEN, 0);
vector pos = c + (real - c) * k;
PlaceScaled(segs[i], pos, width * k, SEG_LEN * k); // scale x/z = width, y = length
}
}
Damage by bounds, not by origin
Inside the beam everything takes 8,000 points per second. Checking the distance to an entity's origin misses buildings and large vehicles whose origin is metres away from the edge the beam touches. The distance to the world bounds is just as cheap and hits the house the beam actually grazes.
vector mins, maxs;
target.GetWorldBounds(mins, maxs);
float dx = Math.Max(Math.Max(mins[0] - p[0], p[0] - maxs[0]), 0);
float dz = Math.Max(Math.Max(mins[2] - p[2], p[2] - maxs[2]), 0);
if (Math.Sqrt(dx * dx + dz * dz) > CORE_RADIUS) // 5 m: the visible beam incl. its glow
continue;
vector hit = Vector(Math.Clamp(p[0], mins[0], maxs[0]), Math.Clamp(p[1], mins[1], maxs[1]), Math.Clamp(p[2], mins[2], maxs[2]));
MyDamage.Apply(target, EDamageType.TRUE, 8000 * dt, hit);
Around the beam a 40 m heat zone works every half second: vehicles take incendiary damage on their burnable zones (they catch fire), infantry takes fire damage, and trees fall. Vanilla destructible trees break on enough damage and fall away from the hit point for explosive damage – putting the hit point on the beam side makes them fall outward, like a blast.
if (BaseTree.Cast(target) && !m_aFelled.Contains(target))
{
m_aFelled.Insert(target);
vector away = target.GetOrigin() - beam;
away[1] = 0;
away.Normalize();
MyDamage.Apply(target, EDamageType.EXPLOSIVE, 20000, target.GetOrigin() - away * 0.5, away);
}
Scorched ground
Every few metres the beam leaves a burning patch and a scorch decal. The decal is projected straight down onto whatever the trace from above hits – terrain, a roof or a wreck.
TraceParam param = new TraceParam();
param.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
param.Start = pos + Vector(0, 3, 0);
param.End = pos - Vector(0, 3, 0);
world.TraceMove(param, null);
if (param.TraceEnt)
world.CreateDecal(param.TraceEnt, pos + Vector(0, 2, 0), Vector(0, -1, 0), 0, 5,
Math.RandomFloat(0, Math.PI2), 9, 1, SCORCH_EMAT, 600, 0xFFFFFFFF); // 10 minutes
{{GUID}}path. Packed game data has no .meta files; the GUIDs of vanilla materials and particles can be looked up in the game's resourceDatabase.rdb.