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

Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2011, 07:55 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

At the moment i about to finish a checkAirfield Routine:

Code:
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;

public class Mission : AMission
{
    AiAirport PlayerStartAirport;
    AiAirport PlayerEndAirport;
    AiAircraft PlayerAircraft;
    
    internal AiAirport getNearestAirfield(Player player)
    {
        AiAirport NearestAirfield = null;
        AiAirport[] airports = GamePlay.gpAirports();
        Point3d PlayerStartPos = player.Place().Pos();

        if (airports != null)
        {
            foreach (AiAirport airport in airports)
            {
                if (NearestAirfield != null)
                {
                    if (NearestAirfield != null)
                        if (NearestAirfield.Pos().distance(ref PlayerStartPos) > airport.Pos().distance(ref PlayerStartPos))
                            NearestAirfield = airport;
                }
                else NearestAirfield = airport;
            }
        }
        return NearestAirfield;
    }


    internal AiAirport getNearestAirfield(AiWayPoint waypoint)
    {
        AiAirport NearestAirfield = null;
        AiAirport[] airports = GamePlay.gpAirports();
        Point3d WaypointPos = waypoint.P;

        if (airports != null)
        {
            foreach (AiAirport airport in airports)
            {
                if (NearestAirfield != null)
                {
                    if (NearestAirfield != null)
                        if (NearestAirfield.Pos().distance(ref WaypointPos) > airport.Pos().distance(ref WaypointPos))
                            NearestAirfield = airport;
                }
                else NearestAirfield = airport;
            }
        }
        return NearestAirfield;
    }
    
    
    internal bool checkAirfield(Player player, AiAirport airport, double maxdistance)
    {
        Point3d PlayerPos = player.Place().Pos();
        GamePlay.gpLogServer(null, "Distanz zum Flugplatz {0}", new object[] {airport.Pos().distance(ref PlayerPos)});  //test
        if (airport.Pos().distance(ref PlayerPos) < maxdistance)
            return true;
        else return false;
    }


    public override void OnBattleStarted()
    {
        base.OnBattleStarted();
        MissionNumberListener = -1;
    }


    private void checkLanded(AiAircraft aircraft)
    {
        if (GamePlay.gpPlayer().Place() != aircraft)
            return;
    }

    
    public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        if (aircraft.Player(0) != null)
        {

            if (checkAirfield(aircraft.Player(0) , PlayerStartAirport, 2000.0))
                GamePlay.gpHUDLogCenter("Mission Successfull");
        }
    }
    
    
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        if (aircraft.Player(0) != null)
        {

            if (checkAirfield(aircraft.Player(0), PlayerStartAirport, 2000.0))
                GamePlay.gpHUDLogCenter("Mission Successfull");
        }
    }



    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);
        
        if (PlayerStartAirport== null)
            PlayerStartAirport = getNearestAirfield(player);

        
        AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay();

        int i = Wp.Length;

        if (i > 0)
        {
            AiWayPoint EndPoint = Wp[i - 1];

            if (PlayerEndAirport == null)
                PlayerEndAirport = getNearestAirfield(EndPoint);
        }
        else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() });
    }
}
Should work but need some tests, above checks if the players StartAirport is the same he landed. Then you should get the message "Mission Successfull"

This
Code:
AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay();

        int i = Wp.Length;

        if (i > 0)
        {
            AiWayPoint EndPoint = Wp[i - 1];

            if (PlayerEndAirport == null)
                PlayerEndAirport = getNearestAirfield(EndPoint);
        }
        else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() });
Looks for the nearest Airfield at last Player Waypoint. But i ve not integrated it in the victory conditions at time.

Last edited by FG28_Kodiak; 10-06-2011 at 08:25 AM.
Reply With Quote
  #2  
Old 10-07-2011, 06:35 AM
dflion dflion is offline
Approved Member
 
Join Date: Nov 2007
Posts: 319
Thumbs up Thankyou FG28_Kodiak

These two script routines look very promising Kodiak. I will wait until you test them further. Thankyou again.
DFLion
Reply With Quote
Reply


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 12:17 AM.


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