Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Not self explanatory code in bombsite location snippet #88

Closed
skirsten opened this issue Jan 28, 2016 · 3 comments
Closed

Not self explanatory code in bombsite location snippet #88

skirsten opened this issue Jan 28, 2016 · 3 comments

Comments

@skirsten
Copy link
Contributor

The following code

var relevantTrigger = parser.triggers.Single(a => a.Index == site);

if ((parser.bombsiteACenter - bombEventArgs.Player.Position).Absolute <
    (parser.bombsiteBCenter - bombEventArgs.Player.Position).Absolute) {
    // planted at A.

    bombEventArgs.Site = 'A';
    parser.bombsiteAIndex = site;
} else if (relevantTrigger.Contains(parser.bombsiteBCenter)) {
    // planted at B.

    bombEventArgs.Site = 'B';
    parser.bombsiteBIndex = site;
}

GameEventHandler.cs Line 303

raises multiple questions:

  1. Why the bounding box check at bombsite b? Is this not sufficient enough:

    if ((parser.bombsiteACenter - bombEventArgs.Player.Position).Absolute <
        (parser.bombsiteBCenter - bombEventArgs.Player.Position).Absolute) {
        // planted at A.
        // set site...
    } else {
        // planted at B.
        // set site...
    }
  2. Why not use only the bounding box:

    var relevantTrigger = parser.triggers.Single(a => a.Index == site);
    
    if (relevantTrigger.Contains(parser.bombsiteACenter)) {
        // planted at A.
        // set site...
    } else {
        // planted at B.
        // set site...
    }

Am I missing something?

Also: Which of the used methods (absolute relative position or bounding box) should be used to identify the bombsite in the BombBeginDefuse and BombAbortDefuse events? (They do not contain site information)

Or should I save the last planted site and use that?

Anyway thanks for the awesome project!

@moritzuehling
Copy link
Contributor

You're right, thanks!

We used only the bounding-box before, this sadly gave some errors on some maps. However, the changed code didn't really fix this, because of the sad error.

You can create a pull-request with any of those fixes, I'm fine with either.

@skirsten
Copy link
Contributor Author

skirsten commented Feb 1, 2016

#89 changed bombsite detection code

@moritzuehling
Copy link
Contributor

Fixed in #89

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants