Page MenuHomeWildfire Games

[Petra/Ai] Use parabolic range calculation when checking range of ranged attacks using elevation bonus from templates
Changes PlannedPublic

Authored by Angen on Sun, Sep 6, 3:52 PM.

Details

Reviewers
None
Summary

This will help ai mainly on flat maps to place foundations out of fire range of enemy structures, so Petra will less likely lose resources because of useless trying to build stuctures again at some place.
This does not solve elevation bonus given by terrain hight or foundations destroyed by enemy ranged units.

Test Plan

Check that number literals are squared correctly.
Check squared parabolic ranges are compared with squared distances.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
/ps/trunk
Lint
Lint OK
SeverityLocationCodeMessage
Errorbinaries/data/mods/public/simulation/ai/common-api/entity.js:984ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Errorbinaries/data/mods/public/simulation/ai/common-api/utils.js:88ESLintBear (no-use-before-define)ESLintBear (no-use-before-define)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:778ESLintBear (no-extra-semi)ESLintBear (no-extra-semi)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:778JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:837ESLintBear (brace-rules/brace-on-same-line)ESLintBear (brace-rules/brace-on-same-line)
Warningbinaries/data/mods/public/simulation/ai/common-api/entity.js:854ESLintBear (brace-rules/brace-on-same-line)ESLintBear (brace-rules/brace-on-same-line)
Warningbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:475ESLintBear (indent)ESLintBear (indent)
Warningbinaries/data/mods/public/simulation/ai/petra/defenseManager.js:595ESLintBear (no-trailing-spaces)ESLintBear (no-trailing-spaces)
Unit
No Unit Test Coverage
Build Status
Buildable 13148
Build 26138: Vulcan BuildJenkins
Build 26137: Vulcan Build (macOS)Jenkins
Build 26136: Vulcan Build (Windows)Jenkins
Build 26135: arc lint + arc unit

Event Timeline

Angen created this revision.Sun, Sep 6, 3:52 PM
Angen requested review of this revision.Sun, Sep 6, 3:58 PM
bb added a subscriber: bb.Sun, Sep 6, 5:38 PM

Shouldn't we do something similar for all attackRange queries in the ai?

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2478–2479

attackRange might be a better name

Angen updated this revision to Diff 13456.Tue, Sep 8, 10:24 PM

use correct elevation range calculation

Successful build - Chance fights ever on the side of the prudent.

builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1525/display/redirect

Angen planned changes to this revision.Tue, Sep 8, 10:30 PM
Angen added inline comments.
binaries/data/mods/public/simulation/ai/common-api/utils.js
30

forgot to rename

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1544

ouch

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
589

hmm, what to do here, it is fishing boat so meh ? but I want to avoid sqrt

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2480

could do radius*radius out of loop

Angen updated this revision to Diff 13457.Tue, Sep 8, 10:37 PM
Angen retitled this revision from [Petra/Ai] Use elevation bonus from template when checking if entity can fire at us to [Petra/Ai] Use parabolic range calculation when checking range of ranged attacks using elevation bonus from templates.
Angen edited the test plan for this revision. (Show Details)Tue, Sep 8, 10:39 PM
Angen planned changes to this revision.Tue, Sep 8, 10:58 PM

dummy
(a+b)*(a+b) != a*a + b*b

Angen added inline comments.Wed, Sep 9, 8:34 AM
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179

need sqrt here

binaries/data/mods/public/simulation/ai/petra/attackPlan.js
1549

issue

1552

range = 8100

binaries/data/mods/public/simulation/ai/petra/defenseManager.js
142

issue

binaries/data/mods/public/simulation/ai/petra/headquarters.js
2480

issue

Stan added a subscriber: Stan.Wed, Sep 9, 8:46 AM
Stan added inline comments.
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179

need sqrt here

Could square the dist ?

Angen added inline comments.Wed, Sep 9, 8:59 AM
binaries/data/mods/public/simulation/ai/petra/attackManager.js
179

hmmm, yes

Nescio added a subscriber: Nescio.Wed, Sep 9, 10:46 AM

loose

Is this some kind of sociolect? I'm asking because I've also observed other team members write ‘loose’ (i.e. set free, release) instead of ‘lose’ (i.e. be deprived of, cease to have) more than once.

Angen added a comment.Wed, Sep 9, 10:48 AM

no, thats just my english, thank you

Angen edited the summary of this revision. (Show Details)Wed, Sep 9, 10:48 AM