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, 01:33 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

I see a little problem
How to handle if one side don't have human pilots. Then your formula tries a division by zero and this will results in an error.

Last edited by FG28_Kodiak; 10-06-2011 at 01:35 PM.
Reply With Quote
  #2  
Old 10-06-2011, 02:12 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by FG28_Kodiak View Post
I see a little problem
How to handle if one side don't have human pilots. Then your formula tries a division by zero and this will results in an error.
Maybe it is possible to check if human pilots > 0 first.

Or maybe divide (1 + friendlyFgtrs + friendlyBmbrs/2) / (1+ enmyFgtrs + enmyBmbrs/2). It will do.

Or we can deny premium planes at all if say other side has less than 2 human players.

edit
What I do not know is how to handle other side players which are still in the menu and not flying. Can they be taken into account? If yes, probably 80% of them should be accounted as fighters and 20% as bombers if you do not mind. But it is not very important I think.

Last edited by Ataros; 10-06-2011 at 02:23 PM.
Reply With Quote
  #3  
Old 10-12-2011, 09:40 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

It looks I am in trouble with my script here too.

Again it works for hosted server killing my engine when required but does not work on dedicated server.

First I used this line as you can see above in my message
Code:
 (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
It did not work online on a dedicated server.

Then I tried to modify actor-damaging script to destroy player plane. The same thing happens. On a dedicated server this script damages abondoned aircrat but my modified methods do not work. But work on hosted server (when I am the server).

OnPlaceEnter check where damagePlayerGroup((actor as AiAircraft)) does not work on a dedi.
Code:
        //checks limited aircraft

        showTestMsg(player);

        if (actor != null && actor is AiAircraft)
        {
            windowOfOp = 10;
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    {
                        current109s++;
                        showTestMsg(player);

                        // !!! test !!!
                        if (current109s > allowed109s) // || current109s > 1) //  !!! test !!!
                        {
                            damagePlayerGroup((actor as AiAircraft));
                            Timeout(12, () =>
                            {
                                msgTooManyAircraft(player);
                                showTestMsg(player);
                            });  

                        }                    
                            break;
                    }
Methods (my methods are in the end)
Code:
 #region Destroy Actors Methods
    // by TheEnlightenedFlorist http://www.airwarfare.com/sow/index.php?option=com_kunena&func=view&catid=43&id=539&Itemid=54
        
    private bool isAiControlledPlane(AiAircraft aircraft)
    {
        if (aircraft == null)
            return false;
 
        //check if a player is in any of the "places"
        for (int i = 0; i < aircraft.Places(); i++)
            if (aircraft.Player(i) != null)
                return false;
 
        return true;
    }
 
    private void destroyPlane(AiAircraft aircraft)
    {
        if (aircraft != null && isAiControlledPlane(aircraft))
            aircraft.Destroy();
    }
 
    private void damageAiControlledPlane(AiActor actorMain)
    {
        foreach (AiActor actor in actorMain.Group().GetItems())
        {
            if (actor == null || !(actor is AiAircraft))
                return;
 
            AiAircraft aircraft = (actor as AiAircraft);
 
            if (!isAiControlledPlane(aircraft))
                return;
 
            if (aircraft == null)
                return;
 
            aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
            aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
            aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
            aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFailure);
            int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
            for (int i = 0; i < iNumOfEngines; i++)
            {
                aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
            }
 
 
            Timeout(240, () =>
            { destroyPlane(aircraft); }
                );
        }
    }
    // Ataros method
    private void destroyPlayerPlane(AiAircraft aircraft)
    {
        if (aircraft != null)
            aircraft.Destroy();
    }

    private void damagePlayerGroup(AiActor actorMain)
    {
        foreach (AiActor actor in actorMain.Group().GetItems())
        {
            if (actor == null ) // || !(actor is AiAircraft))
                return;

            AiAircraft aircraft = (actor as AiAircraft);

            if (!isAiControlledPlane(aircraft))
            {
                if (aircraft != null)
                {
                    aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
                    aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
                    aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
                    aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFailure);
                    int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
                    for (int i = 0; i < iNumOfEngines; i++)
                    {
                        aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
                    }

                    //Timeout(60, () =>
                    //     { destroyPlayerPlane(aircraft); }
                    //    );
                }
            }
        }
    }

    #endregion
Sure it must be something basic that I can not see with my eyes. Attached a complete script.
Attached Files
File Type: zip r_steppe1.4.zip (5.9 KB, 1 views)

Last edited by Ataros; 10-12-2011 at 09:43 PM.
Reply With Quote
  #4  
Old 10-13-2011, 04:37 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Its a bug in dedi. As Workaround i use in my penalty script:
Code:
private void DoDamageToAirplane(AiAircraft aircraft)
    {
        if (!aircraft.IsAirborne())
        {
            // plane on ground Undercarriage cut off
            aircraft.cutLimb(part.LimbNames.WingL0);
            aircraft.cutLimb(part.LimbNames.WingL1);
            aircraft.cutLimb(part.LimbNames.WingL2);
            aircraft.cutLimb(part.LimbNames.WingL3);
            aircraft.cutLimb(part.LimbNames.WingL4);
            aircraft.cutLimb(part.LimbNames.WingL5);
            aircraft.cutLimb(part.LimbNames.WingL6);
            aircraft.cutLimb(part.LimbNames.WingL7);
            aircraft.cutLimb(part.LimbNames.WingR0);
            aircraft.cutLimb(part.LimbNames.WingR1);
            aircraft.cutLimb(part.LimbNames.WingR2);
            aircraft.cutLimb(part.LimbNames.WingR3);
            aircraft.cutLimb(part.LimbNames.WingR4);
            aircraft.cutLimb(part.LimbNames.WingR5);
            aircraft.cutLimb(part.LimbNames.WingR6);
            aircraft.cutLimb(part.LimbNames.WingR7);
        }
        else
        {
            // plane in Air Tail cut off
            aircraft.cutLimb(part.LimbNames.Tail0);
            aircraft.cutLimb(part.LimbNames.Tail1);
            aircraft.cutLimb(part.LimbNames.Tail2);
            aircraft.cutLimb(part.LimbNames.Tail3);
            aircraft.cutLimb(part.LimbNames.Tail4);
            aircraft.cutLimb(part.LimbNames.Tail5);
            aircraft.cutLimb(part.LimbNames.Tail6);
            aircraft.cutLimb(part.LimbNames.Tail7);
        }
    }
Its not the best solution but it works on dedi, sometimes you get a index out of bound error in console, it depends on aircrafttype you use, not figuered out at the moment , normaly you must test every aircraft which parts could be damaged, but its not a critical error.

At the moment i working on a script, which remove and add planes (on the fly) to the birthplaces, so its no longer nessesary to damage 'overused' planes. But in the moment its in a early stage.
Reply With Quote
  #5  
Old 10-13-2011, 06:28 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Thank you!
Maybe you can get Length of LimbNames.Tail from the game same as with engines here and run a loop? Tail would do the job in the air too I think.

Code:
                    int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
                    for (int i = 0; i < iNumOfEngines; i++)
                    {
                        aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
                    }
Reply With Quote
  #6  
Old 10-19-2011, 04:01 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

1.11 version up on Repka #3 for testing
Attached Files
File Type: zip r_steppe1.11.zip (24.4 KB, 15 views)
Reply With Quote
  #7  
Old 10-20-2011, 09:49 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

I have a more general question which I hope someone can answer:

My mission loads submission with some parameters (attacker army, mission type, attack sector, etc), then gets trigger status, calculates mission results and shows results messages using the same parameters. It goes fine when submissions are loaded one by one.

I want to add different types of submissions and make them overlap in time. Naturally I have to store parameters of every submissions as different variables to prevent them mixing up.

How can I do this? Should I create a list for each parameter and send it to array when each new submission loads or there is a more elegant way to do this. I will not have more then 10 submissions going on simultaneously and do not have to create arrays with the length of total past submissions quantity.
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 01:54 AM.


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