Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-26-2012, 03:01 PM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default example

here are two codes to help

sorry no time to explain


Code:
    private void FindNearestMarker(out Point2d target, Point2d basePoint, int army)         // piano, I find the nearest marker to the country
    {
        Point2d res = new Point2d(-1,-1);
        double minDist = 9999999999.9 ;
        foreach (MissionMarker mm in MissionMarkers)
        {
            if (mm.army == army)
            {
                double curDist = Math.Sqrt(Math.Pow((basePoint.x - mm.x),2 )+ Math.Pow((basePoint.y - mm.y),2));
                if (curDist < minDist)
                {
                    minDist = curDist;
                    res.x = mm.x; res.y = mm.y;
                }
            }
        } 
        target = res;
    }
Code:
    private bool PointBetween(double intervalPoint1,double intervalPoint2,double point)         // kh-n checks whether the point lies in the interval
    {
        return ((point > Math.Min(intervalPoint1, intervalPoint2)) && (point < Math.Max(intervalPoint1, intervalPoint2)));
    }

    private void FindFinishPoint(out Point2d target,Point2d startPoint, int army)               // piano, I find the final destination
    {
        Point2d res = new Point2d(-1, -1);
        int enemyArmy = (army == 1) ? 2 : 1;        
        Point2d nearestEnemyMarker;
        Point3d startPos = new Point3d(startPoint.x, startPoint.y,0);
        FindNearestMarker(out nearestEnemyMarker, startPoint, enemyArmy);                       // first find the closest enemy marker
        AiActor nearestEnemyGG = FindGroundTarget(enemyArmy, startPos);                         // then the nearest group of enemy
        if (nearestEnemyGG != null)
        {
            if ((PointBetween(startPoint.x, nearestEnemyMarker.x, nearestEnemyGG.Pos().x)) && (PointBetween(startPoint.y, nearestEnemyMarker.y, nearestEnemyGG.Pos().y)))
            {
                res.x = nearestEnemyGG.Pos().x;
                res.y = nearestEnemyGG.Pos().y;
            }
            else res = nearestEnemyMarker;                                                      // and select one of them is closer
        }
        target = res;
    }
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.