-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draw nano range on transport #4035
base: master
Are you sure you want to change the base?
Conversation
Draw a circle around a transport carrying a nano when its about to unload This commit solves the issue beyond-all-reason#3912 Have transport carrying conturret show buildrange on unload command To test there are 3 scenarios: 1. A transport carrying a nano, when the unload command is executed, it shoud draw a circle on the ground with radius equal to the range of the nano 2. A transport carrying any unit but a nano, when the unload command is executed it shouldn't draw the circle 3. Several transports carrying units nanos and others than nanos, when the unload command is executed it should draw a circle on the ground with radius equal to the range of the nano
function MinValue(table) | ||
local min = table[1] | ||
for i = 2, #table do | ||
if table[i] < min then | ||
min = table[i] | ||
end | ||
end | ||
return min | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to use an existing common table function inside https://github.com/beyond-all-reason/Beyond-All-Reason/blob/master/common/tablefunctions.lua. If no suitable function exists, adds the new functionality there.
-------------------------------------------------------------------------------- | ||
local circleDivs = 96 | ||
local range | ||
local isNanoTC = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local isNanoTC = {} | |
local isImmobileBuilder = {} |
Or isConstructionTurret
or something similar. For code clarity, avoid using abbreviations, short forms, and slang.
local glLineWidth = gl.LineWidth | ||
local glDrawGroundCircle = gl.DrawGroundCircle | ||
|
||
for udid, ud in pairs(UnitDefs) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for udid, ud in pairs(UnitDefs) do | |
for unitDefId, unitDef in pairs(UnitDefs) do |
Avoid short forms
-------------------------------------------------------------------------------- | ||
--vars | ||
-------------------------------------------------------------------------------- | ||
local circleDivs = 96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local circleDivs = 96 | |
local circleDivisions = 96 |
Or circleSegments
or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change spaces -> tabs
if transportWithNano[transportID] then | ||
transportWithNano[transportID] = nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if transportWithNano[transportID] then | |
transportWithNano[transportID] = nil | |
end | |
transportWithNano[transportID] = nil |
No need to check if value is not nil if just setting it to nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the transport is destroyed while carrying the nano? Should also do a removal inside the UnitDestroyed
callin.
Tested it, looks great in-game. Could this be extended to transportable turrets as well? |
Work done
This commit solves the issue #3912 - Have transport carrying conturret show buildrange on unload command
The new file draws a circle around a transport carrying a nano when its about to unload
Addresses Issue(s)
Test steps
To test there are 3 scenarios:
Screenshots:
BEFORE:
AFTER: