Proximity detection for weapon projectile

Is there possible to get same kind proximity detection to weapon projectile (like Disk) what works like Mine? I can find the "proximity = x.x;" setting but it does not work as I tought. Something is missing. Idea is to build up a flak turret where the projectile needs to explode on X radius of the target (enemy or friend).

Comments

  • I think something along the lines of the following pseudo-code might work
    function MySnazzyWeapon::onFire(...) {
        %p = parent::onFire(...);
        majikProjectileStuffs(%p);
    }
    
    
    function majikProjectileStuffs(%proj) {
        if (!isobject(%proj)
            return;
    
        // See if any player is within range
        // If so, explodify
    
        schedule(100, 0, majikProjectileStuffs, %proj);
    }
    
  • Thanks!

    What is the "schedule (100, 0,..." part? Does it tell the range or timing of explode when comes to proximity?

    Need to check out that do I get that code work...
  • the schedule() bit makes it come back to that function roughly every 100 milliseconds.
    Implementation to determine if a player/client is within range, and explode the projectile is left to you.

    I'd suggest looping through the client-group and using the client.player variable to check distance of players from the projectile with vectorDist()
  • I'd suggest using a containerRadiusSearch, because you can check for different object types with it.
  • I'd suggest using a containerRadiusSearch, because you can check for different object types with it.

    What you mean by that?
  • keen mentioned trying something like this and saying that it was basically a crapshoot
  • It's possible, but tedious. Good luck trying to get the projectile to detonate though, that's the fun part >.o
  • I have found now a tutorial for a flak. http://www.advancedmod.com/Tribes2/tutorials/flakgun.txt but it seems to do same thing as normal projectiles when they explode on hit, Was it a target or ground/building.

    I believe I have not understood the #step 7 part on the tutorial. Specially the "should become:" part. Should I replace the top with the bottom version or what.

    Or it might that latest patch has made that function non-working state. Intreasting idea at least.
  • I'd suggest using a containerRadiusSearch, because you can check for different object types with it.

    What you mean by that?

    Simply this:
    %rad = 50;
    %TargetSearchMask = $TypeMasks::PlayerObjectType
    InitContainerRadiusSearch(%pos,%rad,%TargetSearchMask);
    while ((%Scanned = ContainerSearchNext()) != 0) {
       if(isObject(%Scanned)){
          //majik stuf here
       }    
    }
    

    that's a container radius search, %pos being the current position of the projectile, %rad being the radius to search, and %TargetSearchMask being the type mask to check. you could add additional checks to see if the target is alive or not, what team they are on, and all, but that's just a basic search.
  • I believe I have not understood the #step 7 part on the tutorial. Specially the "should become:" part. Should I replace the top with the bottom version or what.

    Yes, replace the top with the bottom part
Sign In or Register to comment.