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-01-2011, 08:04 AM
dflion dflion is offline
Approved Member
 
Join Date: Nov 2007
Posts: 319
Smile Probably a complete script?

Thanks FG28_Kodiak,
As I am in the steep learning curve in how to do 'scripting', I would like a complete script. I appreciate your help and it will help me to learn more about scripting in my next campaigns.

If you need to see the complete campaign, contact me privately through the forum.

DFLion
Reply With Quote
  #2  
Old 10-06-2011, 07:05 AM
dflion dflion is offline
Approved Member
 
Join Date: Nov 2007
Posts: 319
Cool Have I scared all the Script writers away?

I have just finished scripting my 'Battle of France' campaign and it seems to be working very well. The only thing that doesn't work is that if you are successful in a mission, then have to leave the game (for some reason), when you come back to the (game) campaign it doesn't start where you left it????

My KG1.111_Ju88 campaign is still not working properly? Need some help 'boys and girls'?

DFLion
Reply With Quote
  #3  
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
  #4  
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

Thread Tools
Display Modes

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 06:49 PM.


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