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 02-16-2012, 09:46 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default Refuel Scripting research

Hi guys, So the other day i decided to look into RRR Refuel, rearm and Repair.

I think this is looking more possible I have located some details about the plane and Fuel.

So I will need some help with working this into script soon I think as I am a little busy with stupid work....I love my work and pays well but is restrictis my flying time

OK so what do I know or what have I found???

Well lets look at two areas.

First the SpitfireMKI Flight model details
Second the aircraft details on the object aircraft


Spitfire Mk.I Flightmodel

//below is the start settings for the plane on spawn "Pneumatics". We could call this up to simulate refuel. Would reset the plane to spawn status but change the 'Empty' to 'Full'

Pneumatics Source Engine0 Pressure 300 lbsqin PrimaryContainer 4 litre Starts Open, Full SecondaryContainer 4 litre Starts Closed, Empty

Below Using this we should be able to assign a fuel % which is usually done when you are in Loadout and slide the fuel bar from 0-100%

WPF.Fuel [%]:
Fuel [%]:
WPF.Fuel weight [kg]:


So the call in the .cs file could be something like.


if [SpitfireMkI]
types Aircraft Stationary
class part.SpitfireMkI
type Fighter
FM FlightModels.SpitfireMkI

Pneumatics Source Engine0 Pressure 300 lbsqin PrimaryContainer 4 litre Starts Open, Full SecondaryContainer 4 litre Starts Closed, Full

or
WPF.Fuel [85%]:





I think we are getting a little closer. Any assistance on this?
__________________
__________________
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

Last edited by hc_wolf; 02-16-2012 at 10:40 AM. Reason: update
Reply With Quote
  #2  
Old 02-16-2012, 10:56 AM
wildwillie wildwillie is offline
Approved Member
 
Join Date: Aug 2010
Posts: 111
Default

This sounds promising !!!

While we are on this topic, couldn't we have engines pre-warmed by script upon spawn in ?

(i.e. OnPlaceEnter - When a player plane has been created, set the temps for each engine/oil to 150/60. Then we would not have to wait 3 minutes on the Allied side just to start moving.)

WildWillie
Reply With Quote
  #3  
Old 02-16-2012, 11:41 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default

Quote:
Originally Posted by wildwillie View Post
This sounds promising !!!

While we are on this topic, couldn't we have engines pre-warmed by script upon spawn in ?

(i.e. OnPlaceEnter - When a player plane has been created, set the temps for each engine/oil to 150/60. Then we would not have to wait 3 minutes on the Allied side just to start moving.)

WildWillie
You can already do that in missions by having planes spawn as idle
__________________
__________________
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
  #4  
Old 02-16-2012, 07:34 PM
ATAG_Bliss ATAG_Bliss is offline
Approved Member
 
Join Date: Mar 2010
Posts: 1,156
Default

The only problem I see with doing this (as the game is currently) is you're only going to refuel/re-arm while on the ground (I know that part is obvious). So you're either going to land/return to base to do it.

Since we don't have the refly button of old, the despawn scripts are used to get rid of landed planes. So the second someone comes in for a landing the timer for that plane's destruction has been started.

Without the old style system of 46 (refly button available only after bail out / landed / crashed / killed) you'll run into planes building up where ever landing zones are. This is assuming 1/2 the people actually use the refuel/rearm option where as the crash landed planes will be piling up as well.

I just don't see how this would work without a significant modification to the despawn scripts (or HINT HINT HINT - Devs make it like 46!!!)
__________________

ATAG Forums + Stats
Reply With Quote
  #5  
Old 02-16-2012, 08:37 PM
wildwillie wildwillie is offline
Approved Member
 
Join Date: Aug 2010
Posts: 111
Default

Quote:
You can already do that in missions by having planes spawn as idle
hc_Wolf -

How do you go about this ? When setting up a spawn point I only see options "Spawn parked" and "parachute" Am I missing something here ?

WildWillie
Reply With Quote
  #6  
Old 02-16-2012, 09:10 PM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default

Quote:
Originally Posted by wildwillie View Post
hc_Wolf -

How do you go about this ? When setting up a spawn point I only see options "Spawn parked" and "parachute" Am I missing something here ?

WildWillie
When you place your plane not the spawn point. Go to the object view and under general you will see the spawn options down the bottom and included is Idle.

Of if you want it in a script use this:

string BPSpawnParked = "1"; // whether to give birth to spawn parked aircraft 1 - yes, 0 -

or
string BPSpawnScramble = "1";
__________________
__________________
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
  #7  
Old 02-17-2012, 04:14 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Quote:
Originally Posted by ATAG_Bliss View Post
The only problem I see with doing this (as the game is currently) is you're only going to refuel/re-arm while on the ground (I know that part is obvious). So you're either going to land/return to base to do it.

Since we don't have the refly button of old, the despawn scripts are used to get rid of landed planes. So the second someone comes in for a landing the timer for that plane's destruction has been started.

Without the old style system of 46 (refly button available only after bail out / landed / crashed / killed) you'll run into planes building up where ever landing zones are. This is assuming 1/2 the people actually use the refuel/rearm option where as the crash landed planes will be piling up as well.

I just don't see how this would work without a significant modification to the despawn scripts (or HINT HINT HINT - Devs make it like 46!!!)
I guess you could add the plane to a array/list of "refueling" planes & change the despawn script to exclude those planes from despawning.
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
Reply With Quote
  #8  
Old 02-17-2012, 06:44 AM
41Sqn_Banks 41Sqn_Banks is offline
Approved Member
 
Join Date: Oct 2007
Posts: 644
Default

Quote:
Originally Posted by hc_wolf View Post
So the call in the .cs file could be something like.


if [SpitfireMkI]
types Aircraft Stationary
class part.SpitfireMkI
type Fighter
FM FlightModels.SpitfireMkI

Pneumatics Source Engine0 Pressure 300 lbsqin PrimaryContainer 4 litre Starts Open, Full SecondaryContainer 4 litre Starts Closed, Full

or
WPF.Fuel [85%]:





I think we are getting a little closer. Any assistance on this?
The mission scripts have only limited access through a defined interface. IIRC there is only read access to these values.


In this post http://forum.1cpublishing.eu/showthr...338#post342338 is a code example that shows how to read parameters from an aircraft using the "getParameter()" function. However IIRC there is no "setParameter()" function to write a value.

Last edited by 41Sqn_Banks; 02-17-2012 at 06:48 AM.
Reply With Quote
  #9  
Old 02-17-2012, 09:53 PM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

Atag my modifierd version is pretty much as main despawner, just altered when things are triggered by timers.
It will be best to post in separate thread, as there are other stuff I have learned I'd like to share.
Reply With Quote
  #10  
Old 02-21-2012, 09:15 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

As 41Sqn_Banks says there is no way to set parameters for a plane via script. So the only way to simulate RRR is to create a new plane and place the player in it.

I've made a example, it's not complete (i will never finished it, no fan of "RRR" ) but may be it shows the direction to go.
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using maddox.game;
using maddox.game.world;
using maddox.GP;


public class Mission : AMission
{
    bool RRRinProgress = false;


    private AiAirport getCurrentAirfield(AiActor actor, double maxdistance)
    {
        AiAirport NearestAirfield = null;
        AiAirport[] airports = GamePlay.gpAirports();

        Point3d actorPos = actor.Pos();

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

        if (NearestAirfield.Pos().distance(ref actorPos) < maxdistance)
            return NearestAirfield;
        else
            return null;
    }


    private bool IsGrounded(AiActor actor)
    {
        if ((actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0)
            return true;
        else
            return false;
    }


    internal bool checkAirfield(AiActor actor, AiAirport airport, double maxdistance)
    {
        Point3d ActorPos = actor.Pos();
        
        if (airport.Pos().distance(ref ActorPos) < maxdistance)
            return true;
        else return false;
    }


    private void CountDown(string Message, string EndMessage, double seconds)
    {
        string tmpMessage = Message + " {0}";
        double count = 0.0;

        while (count < seconds)
        {
            Timeout(count++, () =>
                {
                    GamePlay.gpHUDLogCenter(null, tmpMessage, new object[] { seconds-- });
                });
        }
        Timeout(count, () =>
        {
            GamePlay.gpHUDLogCenter(null, EndMessage, null);
        });
    }

    public void SetMainMenu(Player player)
    {
        GamePlay.gpSetOrderMissionMenu(player, false, 0, new string[] { "RRR" }, new bool[] { true });
    }


    public void SetRRRMenu(Player player)
    {
        if (IsGrounded(player.Place()) && !RRRinProgress )
            GamePlay.gpSetOrderMissionMenu(player, false, 10, new string[] { "Refuel, Rearm, Repair current Plane"}, new bool[] { true });
        else
            GamePlay.gpSetOrderMissionMenu(player, false, 11, new string[] { "Not possible" }, new bool[] { false });
    }


    public override void OnOrderMissionMenuSelected(Player player, int ID, int menuItemIndex)
    {

        if (ID == 0)
        {
            if (menuItemIndex == 1)
            {
                SetRRRMenu(player);
            }
        }
        if (ID == 10)
        {
            if (menuItemIndex == 1)
            {
                changePlayerPlane(player, 10);
                SetMainMenu(player);
            }
        }
        if (ID == 11)
        { //return to main menu
            SetMainMenu(player);
        }
    }

    //not finished yet - a lot of work to do at the moment only Airgroup, AircraftType and Location is handled
    internal ISectionFile CreateNewPlaneAtAirfield(AiAirport airport, AiActor actor)
    {
        if (actor == null) return null;
        if (!(actor is AiAircraft)) return null;
        

        ISectionFile f = GamePlay.gpCreateSectionFile();
        string sect;
        string key;
        string value;

        string[] splittet = (actor as AiAircraft).AirGroup().Name().Split(':');
        string airgroupname = splittet[1];

        sect = "AirGroups";
        key = airgroupname;
        value = "";
        f.add(sect, key, value);

        sect = airgroupname;
        
        f.add(sect, "Flight0", "1");

        key = "Class";
        value = (actor as AiAircraft).InternalTypeName().Replace("bob:", "");
        f.add(sect, key, value);

        f.add(sect, "Formation", "LINEABREAST"); 
        f.add(sect, "CallSign", "26");
        f.add(sect, "Fuel", "100");
        f.add(sect, "Weapons", "1 1");
        f.add(sect, "SetOnPark", "1");
        f.add(sect, "Idle", "1");
        f.add(sect, "Skill", "0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3");

        sect = airgroupname + "_Way";
        key = "TAKEOFF";
        value = airport.Pos().x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + airport.Pos().y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + "  0 0";

        f.add(sect, key, value);

        return f;
    }


    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        MissionNumberListener = -1;
    }


    private void changePlayerPlane(Player player, double seconds)
    {
        RRRinProgress = true;
        CountDown("Rearming/Refueling finished in:", "Finished", seconds);

        int newMissionNumber = GamePlay.gpNextMissionNumber();

        Timeout(seconds, () =>
            {
                
                GamePlay.gpPostMissionLoad(CreateNewPlaneAtAirfield(getCurrentAirfield(player.Place(), 700), GamePlay.gpPlayer().Place()));
                
            });

        string CurrentName = player.Place().Name();
        string[] tmpString = CurrentName.Split(':');

        string NewActorName = newMissionNumber + ":" + tmpString[1];

        Timeout(seconds+1, () =>
        {
            AiActor NewActor = GamePlay.gpActorByName(NewActorName);

            if (NewActor != null)
                player.PlaceEnter(NewActor, 0);

            AiActor OldActor = GamePlay.gpActorByName(CurrentName);
            if (OldActor != null)
                (OldActor as AiAircraft).Destroy();
            
            RRRinProgress = false;
        });
    }


    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        SetMainMenu(player);
    }
}
The script copy player plane with "CreateNewPlaneAtAirfield" (this part is not complete at the moment it only copy the Airgroup, PlaneType and uses the AirfieldLocation) after a countdown then places the player in the new one and Destroy the old one.

You can start the "RRR-Simulation" with the Mission-Menu
TAB->4
Attached Files
File Type: zip RRRTest.zip (2.2 KB, 12 views)

Last edited by FG28_Kodiak; 02-21-2012 at 09:20 AM.
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 02:15 AM.


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