Author Topic: fxDTSBrick::onFakeDeath  (Read 1971 times)

Code: [Select]
        function fxDTSBrick::onFakeDeath(%brick)
        {
                parent::onFakeDeath(%brick);
                initContainerRadiusSearch(%brick.getPosition(), 100, $TypeMasks::FxBrickObjectType);
                while(%zone = containerSearchNext())
                {
                        //We now have all of the bricks, so let's get the closest Zone.
                        if(%zone.isZoneBrick)
                        {
                                messageAll('', "\c6Closest Zone Detected at " @ %zone.getTransform() @ " (brick " @ %zone @ ")");
                                %bricksZone = %zone;
                                break;
                        }
                }
        }

This code should theoretically take an exploded brick, get the nearest zone and set that to %bricksZone, but when it runs:

Code: [Select]
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -154 -73 8 1 0 0 0 (brick 4555)
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Closest Zone Detected at -154 -73 8 1 0 0 0 (brick 4555)
Even though that I only fire it once, on one brick. 7397 is the closest zone, but for some reason it detects 4555.

If I do it a Sniper Rifle (instead of a Rocket)
it does
Code: [Select]
Closest Zone Detected at -169.5 -158.5 2 0 0 1 1.5708 (brick 7397)
Which is correct.

Anyone know why this code is firing a ton of times when I do it with the rocket?

Is the rocket destroying it with direct or radius damage? I would guess radius.

Is the rocket destroying it with direct or radius damage? I would guess radius.

Yeah, it's radius.


you could set a temporary variable on the brick if a zone is nearby so that you don't do multiple searches, and then reset it when it respawns

you could set a temporary variable on the brick if a zone is nearby so that you don't do multiple searches, and then reset it when it respawns

Code: [Select]
        function fxDTSBrick::onFakeDeath(%brick)
        {
                parent::onFakeDeath(%brick);
                initContainerRadiusSearch(%brick.getPosition(), 100, $TypeMasks::FxBrickObjectType);
                if(%brick.closeZone) { return; }
                while(%zone = containerSearchNext())
                {
                        //We now have all of the bricks, so let's get the closest Zone.
                        if(%zone.isZoneBrick)
                        {
                                messageAll('', "\c6Closest Zone Detected at " @ %zone.getTransform() @ " (brick " @ %zone @ ")");
                                %brick.closeZone = %zone;
                                break;
                        }
                }
        }

You mean like that?

Code: [Select]
%closestBrickDist=100;
while(%zone = containerSearchNext())
{
    if(%zone.isZoneBrick)
    {
        if((%dist = vectorDist(%brick.getPosition(), %zone.getPosition())) < %closestBrickDist)
        {
            messageAll('', "\c6Closest Zone Detected at " @ %zone.getTransform() @ " (brick " @ %zone @ ")");
            %brick.closeZone = %zone;
            %closestBrickDist = %dist;
        }
    }
}

By keeping track of the closest brick you should be able to shut out false positives.

Code: [Select]
%closestBrickDist=100;
while(%zone = containerSearchNext())
{
    if(%zone.isZoneBrick)
    {
        if((%dist = vectorDist(%brick.getPosition(), %zone.getPosition())) < %closestBrickDist)
        {
            messageAll('', "\c6Closest Zone Detected at " @ %zone.getTransform() @ " (brick " @ %zone @ ")");
            %brick.closeZone = %zone;
            %closestBrickDist = %dist;
        }
    }
}

By keeping track of the closest brick you should be able to shut out false positives.

Awesome. Thanks, i'll try it and lock up the thread if it all goes well.

Actually, as a side note you may want to move the messageAll to right after the loop.

Actually, as a side note you may want to move the messageAll to right after the loop.

why is that?

why is that?
Because that way it'll only announce to the server once, instead of every time it finds a brick that's closer than a previously found one.

Because that way it'll only announce to the server once, instead of every time it finds a brick that's closer than a previously found one.

oh sorry I misread your original statement and didn't get it. I see.

Code works amazingly. Thanks trin
« Last Edit: July 28, 2013, 04:05:46 PM by PeeEsPee »

This thread needs more avatars