beyond-all-reason / beyond-all-reason/RecoilEngine

Lua functions to show/hide all or specific unit range circumferences (attack, build, radar, sonar, etc.)

Open
#1,660 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
683
Forks
293
Avg merge
3d 2h
Merged PRs (30d)
40

Description

This is a new feature request, affects all engine builds.

Units have these range types : https://github.com/beyond-all-reason/spring/blob/BAR105/cont/cmdcolors.txt#L81

That file allows game devs to tweak the colors, but there doesn't seem to be a way to dynamically control when and where they're drawn.
Sometimes it's when issuing attack command while a unit is selected, others when holding shift while hovering the mouse pointer over a unit. Sometimes we'd like to draw death blast radius or weapon ranges when moving around the cursor when placing buildings and those ranges may dynamically differ from the weapondef due to game mechanics like upgrades.

Add lua functions to force the engine to:

  • hide all or some of them for a given unit
  • show for a given unitId, rangeType, rangeMult, weaponNumber(optional)
  • show for a given unitDefId, position,rangeType, rangeMult, weaponNumber(optional)
  • show a weapon attack range for a given weaponDef table at a given position

These would be called on widget:DrawWorld() and show and hide commands could apply to the current draw frame only, relative to the default engine behavior.

example:
-- hide a specific type or all types, for a specific unit or all units
Spring.HideRangeCirc([unitId][,rangeType])

-- show range circumference for a specific unit
Spring.ShowUnitRangeCirc(unitId,rangeType,rangeMult[, weaponNumber])

-- show range circumference for a specific unitDef and position
Spring.ShowUnitDefRangeCirc(unitDefId, x, y, z, rangeType, rangeMult[, weaponNumber])

-- show attack range circumference for a specific weaponDef and position
Spring.ShowWeaponDefRangeCirc(x, y, z, weaponDefTable)

Not sure how it's implemented atm, but instead of being valid for only one draw frame, the circumferences could be some kind of entity like ground decals which could be created with an id returned from the "show" calls and be drawn until explicitly destroyed by Spring.DestroyRangeCirc(circId)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with cont/cmdcolors.txt and the engine path that draws the listed range types, then inspect how widget:DrawWorld() currently triggers range rendering. Define the Lua API for hiding and showing unit, unitDef, and weaponDef circumferences, including frame lifetime and optional weapon arguments. Done means the requested functions work for the described cases and their behavior is covered by appropriate engine tests or verified examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
api, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.