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 07-22-2011, 06:10 AM
fearlessfrog fearlessfrog is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default Speedbar

I wrote a small c# script to display an IL2-style 'speed bar' in CoD. It's not great, but was fun to do. It's in this thread here:

http://simhq.com/forum/ubbthreads.ph...e_airspee.html

Since a few google searches led me to the people helping to explore scripting here, it seems proper to post back in-case it helps others.

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


public class Mission : AMission
{
    private double nextMsgTime = 0;
                        
    public override void OnTickGame()
    {
        {
            base.OnTickGame();
            
            if (Time.current() > nextMsgTime)
            {
                nextMsgTime = Time.current() + 3.0; // 3 ish seconds to next message
                
                // Leave this in if you want to test a timer
                //GamePlay.gpHUDLogCenter("Time elapsed (in seconds) = " + Time.current() + 
                //    ", next message will be at " + nextMsgTime);
                
                if (GamePlay.gpPlayer() != null) // check if we have a player.
                {
                    if (GamePlay.gpPlayer().Place() != null)
                    {
                        Player me = GamePlay.gpPlayer();
                        Player[] all = { me };

                        AiActor where = me.Place();
                        Point3d pos = me.Place().Pos();
                        
                        double height = ((pos.z + 62.5) / 306.5) * 1000;

                        AiAircraft aircraft = (GamePlay.gpPlayer().Place() as AiAircraft);
                        double ias = aircraft.getParameter(part.ParameterTypes.I_VelocityIAS, 0);                        
                        double altitude = aircraft.getParameter(part.ParameterTypes.I_Altitude, 0);
                        double mag_compass = aircraft.getParameter(part.ParameterTypes.I_MagneticCompass, 0);
                        double rep_compass = aircraft.getParameter(part.ParameterTypes.I_RepeaterCompass, 0);

                        double z_altitude = aircraft.getParameter(part.ParameterTypes.Z_AltitudeMSL, 0);
                        double z_ias = aircraft.getParameter(part.ParameterTypes.Z_VelocityTAS, 0);
                        double z_orientation = aircraft.getParameter(part.ParameterTypes.Z_Coordinates, 0);

                        GamePlay.gpLogServer(all, 
                                    "Frogbar v0.1:           HDG: " +
                                    mag_compass.ToString("0") +
                                    "           ALT: " +
                                    height.ToString("0") +
                                    "           SPD: " +
                                    ias.ToString("0"), null);
                    }
                }
            }                       
        }     
    }
}
Cheers!

Last edited by fearlessfrog; 07-22-2011 at 06:28 AM.
Reply With Quote
  #2  
Old 07-22-2011, 09:19 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Thank you for posting.

It is server side script for online players I assume.

But for offline players it could be useful to know how to install it.
Reply With Quote
  #3  
Old 07-22-2011, 05:25 PM
fearlessfrog fearlessfrog is offline
Approved Member
 
Join Date: Jul 2010
Posts: 64
Default

Hi Ataros,

Actually I've only ever tried it single player.

To use it then take the script text and make a 'same-name-as-mission-file.cs' and place it next to the existing .mis file - if you then configure a small window (i.e. 1 line, vertically wide) then you can 'simulate' the speedbar as in IL2.

To try it quickly you can use the Extras / Full Mission Builder and save a mission, i.e. 'test1.mis' and then take the above script and save it as a file called 'test1.cs' and put it next to the .mis file in the /missions directory.

It was just a quick thing to try out, and not a proper speedbar to always play with, but it's great that so much is accessible via the API.

Cheers

Last edited by fearlessfrog; 07-22-2011 at 06:04 PM.
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:47 PM.


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