Results 1 to 22 of 22

Thread: TWC Dogfight PvP

  1. #1
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    TWC Dogfight PvP

    Working on a PVP server and coding for scoring returning to base. Got into some great battles today with Val_Tmn bringing a variety of 109 planes to DOWN the TWC_BlacKnight. Here is my youtube channel- pure edge of the seat. After landing just jump a few minutes ahead: https://www.youtube.com/watch?v=PmbAASj_HCE

    Thanks Val for stopping by!

    Hope to see a few more drop in!

  2. #2
    Veteran Combat pilot Lorena's Avatar
    Join Date
    Nov 2017
    Location
    São Paulo / Brazil
    Posts
    304
    Post Thanks / Like
    Total Downloaded
    98.49 MB

    Re: TWC Dogfight PvP

    that is what i am talking about!
    PC: MSI 1080ti Sea Hawk | Gigabyte Z170x Gaming 7 | Intel i5 6600k @4.2gz | Noctua dh-14 |Thermaltake Versa N21 | 32gb Corsair Vengeance LPX ddr4 | Thermaltake tr2 rx 850w | 960evo NVMe SSD 250gb| 2 x 34` LG 34um67 | HyperX Cloud Stinger | Razer Deathadder v2| Trackir 4 | Microsoft ForceFeedback 2 | Ttesports Challenger keyboard |Windows 10 Enterprise x64 |

    VR: REVERB g2 2160x2160 per eye
    Nvidia driver version: 536.23

  3. #3
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Need some help implementing a scoring script...

    1. First need a plane list for Allied and German.
    int ScoreRed = 0;
    int ScoreBlue = 0;

    private string[] RedPlanesSet = new string[] // описание наборов самолётов на спаунточках разных стран
    { "Aircraft.SpitfireMkIIa",
    "Aircraft.SpitfireMkI",
    "Aircraft.SpitfireMkIa",
    "Aircraft.HurricaneMkI_dH5-20",
    "Aircraft.HurricaneMkI"
    };

    private string[] BluePlanesSet = new string[]
    { "Aircraft.Bf-110C-7",
    "Aircraft.Bf-110C-4",
    "Aircraft.Bf-109E-3B",
    "Aircraft.G50",
    "Aircraft.Bf-109E-3",
    "Aircraft.Bf-109E-1"
    };
    2. Plane shot down 10 points- twin engine fighter 20 points
    3. If you die you lose 5 points for your team Red or Blue.
    4. If you parachute or crash land you just get the 10 points.
    5. If you make it to base and land you get X2 the points.
    6. If you complete more then 4 sorties you get 100 points.
    7. If you complete more then 8 you get 200 points.

    In the 1.07 sample file there is Red and Blue points for targets but nothing for planes...

    Also a mission reload if the points are achieved. So that we can rotate between the 2 maps.

    ANYHELP would greatly be appreciated...
    Last edited by BlacKnight; Nov-22-2022 at 14:30.

  4. #4
    Manual Creation Group DerDa's Avatar
    Join Date
    Apr 2015
    Location
    Heidelberg
    Posts
    2,137
    Post Thanks / Like
    Total Downloaded
    280.96 MB

    Re: TWC Dogfight PvP

    Sorry, I don't understand PvP.

    If this is a dogfight server, why include Blennie and Heinkels (ok, ok I had a lot of fun using the Blennie as fighter, but not everybody is as crazy as me).
    Why no 109 E-4s (Blue will whine)
    And why add the DH Hurri, I don't think anybody ever used it (I'd prefer a Blenheim ...)

  5. #5
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    DerDa that was a copied list from a classic script...

    Yes, it is a Dogfight Server no bombers!

  6. #6
    Manual Creation Group Maru's Avatar
    Join Date
    May 2016
    Posts
    807
    Post Thanks / Like
    Total Downloaded
    213.59 MB

    Re: TWC Dogfight PvP

    Looks fun, PvP is what I enjoy the most, DerDa PvP stands for Player versus Player.
    Blacknight have you ever played the gun game mode? Would be nice to implement this in your TWC DogFight PvP Server.

    I explain in short, basically only the slowest and "worst" aircrafts are available at the lowest amount of points, getting more points grants you better aircrafts, or the opposite : )
    this will avoid pilots using the best top aircraft all the time which is boring because there won't be much diversity.

  7. #7
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Maru,

    Sounds like fun could put a Map in the rotation with older birds as well, but still looking for a unique scoring and plane play set up. Server is active with missions in the TAB Menue if you join with friends, but once you get over 6 pilots then the missions deactivate.

    So RAF and LW can call in 4, 8, or 12 fighters and perfecting the fighter script with missions that load to improve the fighters and make them more human-like.

    Thanks hope this catches on.
    Last edited by BlacKnight; Nov-22-2022 at 14:34.

  8. #8
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: TWC Dogfight PvP

    Quote Originally Posted by BlacKnight View Post
    Need some help implementing a scoring script...

    ANYHELP would greatly be appreciated...
    The Sample Multiplayer Mission has a module "ServerStats" and if you look in CServerStats-v1.0.0-Mission.cs at method OnActorDead() it might give you ideas.

  9. Likes Sleepy_Fly liked this post
  10. #9
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Ok, Time to test the Server Numbers- Looking for a complete overload this Saturday Nov.26th at 2pm Eastern USA.
    Penalty for leaving and death is set to 30sec for now with any suggestions on kick and ban script for leaving in flight????

    Scoring is good for planes shot down still working on code for OnAircraftLanded for sortie complete Kills X4 and then OnAircraftCrashLanded Kills X2 & OnParachuteLanded Kills X2.

    OnParachuteFailed -10pts

    Also under on 4 consecutive sorties a bonus of 100 team points.

    Bases will be extremely guarded.

    Val wanted a closer Air spawn at 10000 and I will put the back one at 15000 with six airfields to spawn from on each side.

    Code for scoring right now looks like this: Works

    Anyone with the skills to make what I listed work would be great: OnAircraftLanded, OnAircraftCrashLanded, OnParachuteLanded etc...

    Code:
            public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
    	{
            base.OnActorDead(missionNumber, shortName, actor, damages);
    //////////////////Penalty
    
            if (actor is AiPerson)
            {
                if ((actor as AiPerson).Player() != null)   // Player is Human
                {
                    /* GamePlay.gpLogServer(null, "{0} - KIA", new object[] { (actor as AiPerson).Player() }); */
                    PilotsInGame.AddDeathToPlayer((actor as AiPerson).Player());
                }
            }	
    ///////////////////////////Points for destroyed units	
            foreach (DamagerScore ds in damages)
            {
                int Addpoints = 0;
                int value;
                bool willReportDead = false;
                string TargetName = "";
    
                if (ds.initiator != null)
                {
                    if (ds.initiator.Actor != null)
                    {
                        if (actor.Army() != ds.initiator.Actor.Army())
                        {
                            if (actor is AiPerson) break; // At moment Pilotkills are not counted ;)
    
                            if (actor is AiAircraft)
                            {
    
    							if (PointsforAirTargets.TryGetValue((actor as AiAircraft).Type().ToString(), out value)) // Erstetzt wegen Stukaproblem
                                    Addpoints = PointsforAirTargets[(actor as AiAircraft).Type().ToString()];
    
                                TargetName = SplitName((actor as AiAircraft).InternalTypeName());
    
                                value = 0;
    							if (actor.Army() == ArmyRed)
                                    {
    								BlueAirKills++;
    								ScoreBlue += Addpoints;
    								if (Addpoints <=0)
    								{ScoreBlue += 3;}
    								GamePlay.gpLogServer(null, "British {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
    								break;
                                if (RAFAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
    									{
    								RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
                                    TargetName += " (" + RAFAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)";  // Shows Counter for Planetype
    									}
    								}
    							
    							else if (actor.Army() == ArmyBlue)
    								{
    								RedAirKills++;
    								ScoreRed += Addpoints;
    								if (Addpoints <=0)
    								{ScoreRed += 3;}
    								GamePlay.gpLogServer(null, "German {0} destroyed - Team scores now: RAF {1}- LW {2}", new object[] { TargetName, ScoreRed, ScoreBlue });
    								break;
    							if (LWAvailableAirplanes.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
    									{
    								LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()] = value - 1;
                                    TargetName += " (" + LWAvailableAirplanes[(actor as AiAircraft).InternalTypeName()].ToString() + " available)";  // Shows Counter for Planetype
    									}
    								
    								}
    						}
    					}
    				}
    			}
    		}
    	}
    Last edited by BlacKnight; Dec-12-2022 at 10:46.

  11. #10
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Another Battle with VAL_Tmn before recording he tried to turn fight slow and those kills where not recorded. After recording Val did a great job in holding his alt and E and schooled me got a few great shots in but I would say we finished even...
    https://www.youtube.com/watch?v=Yr-obUIziNE

    Really hoping we get great numbers on tomorrow when you die and bail should be ok but if you end up with a death penalty go back to a base till the thirty secs ticks down then come back in at airspwan...

  12. #11
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Finishing Tobruk Dogfight Server for the rotation...

  13. #12
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Event Today Nov 26th at 3 pm Eastern USA. Hope to get a large number on to test the server output. Just a Dogfight Mid Channel bases set at 10 and 15000 ft for airspawn, still working on scoring for sorties calc. Anyway been fun fighting those that want to just turn and burn.

    BlacKnight

  14. Likes Sleepy_Fly, ATAG_Snapper, OBT~Mikmak liked this post
  15. #13
    Supporting Member
    Join Date
    Oct 2020
    Posts
    198
    Post Thanks / Like
    Total Downloaded
    197.43 MB

    Re: TWC Dogfight PvP

    Quote Originally Posted by BlacKnight View Post
    Event Today Nov 26th at 3 pm Eastern USA.
    What's the GMT time ?
    "You can teach monkeys to fly better than that!"

    Win 11 Pro - I5-12600KF - 32GB Ram - RTX 3080 TI 12GB (non OC) - SSD Sata 970 GBB (System) - NVMe 980 GB (games storage) - Lenovo 27'' 144Hz - HP Reverb G2 v2 -
    WMR environment : Empty room (SkySpaces) - SteamVR resolution : 2192x2144 (48%)
    nVidia driver : 536.23

  16. #14
    Ace Bonditaria's Avatar
    Join Date
    Oct 2015
    Location
    Rotterdam
    Posts
    1,151
    Post Thanks / Like
    Total Downloaded
    2.82 GB

    Re: TWC Dogfight PvP

    Quote Originally Posted by Sleepy_Fly View Post
    What's the GMT time ?

    ASUS TUF Gaming A15 FA507NV, AMD Ryzen 7 7735HS CPU, NVIDIA GeForce RTX 4060 Laptop GPU, 8 GB GDDR6 VRAM, 16 GB DDR5 RAM, 512 GB SSD, Windows 11 Home 23H2, VPC MongoosT-50 Throttle, VKB Gladiator Pro, MFG Crosswind, Wheel Stand Pro, EIZO CS240, Track-IR 5

  17. Likes Sleepy_Fly, BlacKnight liked this post
  18. #15
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    OK, Map Rotation is in and if their are any other changes I need to make in plane set let me know. Should be smooth!

    Also Map is set up for three teammates to come in call a group of four planes and get into a fight, once that hits four missions can not be loaded. The AI is a personal set each plane has a personal flight characteristics.

    Last the rotation will be up constant now and I will add a group of 6 and then 12: so you three can get into a right bloody fight!

    Anyway

    I am going to let this run through the weekend and see how it goes.

    Working on Victory for number of Kills and should we throw in Model and type plane count....

    Last will be a stats page!!!! Could use some help setting this up lol!

  19. Likes ATAG_Bubba liked this post
  20. #16
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Curious as to the max speed: under socket in the server.

    We are sert to lan but the socket is forcing us back down to 10000...

    udp maxChannels: 255 maxSpeed: 10000 bytes/sec
    steam maxChannels: 255 maxSpeed: 10000 bytes/sec

    Just curious why it is not LAN Setting-

    BlacKnight

  21. #17
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    So, I created mission for those that log on and want an AI scrap. I have been working hard on the code to make sure they stay in the fight till the bitter end. Once 6 players enter the ARENA the Mission launcher gets locked.

    Second- Looking if anyone has corrected Salmos auto airfield AA generation script:

    Code:
    using System.Text;
    using System;
    using System.Collections;
    using maddox.game;
    using maddox.game.world;
    using part;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Globalization;
    using System.Reflection;
    using maddox.GP;
    using System.Text.RegularExpressions;
    
    
    public class Mission : AMission
    {
        Random random = new Random();
    
        // random AA on battle startup (generate random AA at airfields on battle start)
        bool GenerateRandomAA = true;               // turn random AA at airfields on/off
        bool SpawnBasesAAOnly = false;              // random AA generated at spawn airfields only
        int ChanceSpawnbaseHasAA = 100;             // percent chance a spawn base has AA defences
        int ChanceNonSpawnbaseHasAA = 0;           // percent chance a non-spawn base has AA defences
        int RedMinAirfieldAA = 10;                   // minimum number of AA units at red airfields
        int RedMaxAirfieldAA = 12;                   // maximum number of AA units at red airfields
        int BlueMinAirfieldAA = 10;                  // minimum number of AA units at blue airfields
        int BlueMaxAirfieldAA = 12;                  // maximum number of AA units at blue airfields
    
        public override void OnBattleStarted()
        {
            base.OnBattleStarted();
            if (GenerateRandomAA ) GenerateRandomAAatAirfields();
        }
    
        public void GenerateRandomAAatAirfields()
        {   // spawn random AA at airfields
            List<string> AlliedAA = new List<string>
            {
                "Artillery.3_inch_20_CWT_QF_Mk_I gb",
                "Artillery.3_7_inch_QF_Mk_I gb",
                "Artillery.Bofors gb",
                "Artillery.20_mm_Flak_38 gb"
            };
    
            List<string> AxisAA = new List<string>
            {
                "Artillery.Flak30_Shield de",
                "Artillery.Flak37 de",
                "Artillery.20_mm_Flak_38 de",
                "Artillery.Zwillingssockel36_GER1 de",
                "Artillery.4_cm_Flak_28 de"
            };
    
            // do some parameter intergity checks
            if (ChanceSpawnbaseHasAA > 100) ChanceSpawnbaseHasAA = 100;
            if (ChanceSpawnbaseHasAA < 0) ChanceSpawnbaseHasAA = 0;
            if (ChanceNonSpawnbaseHasAA > 100) ChanceNonSpawnbaseHasAA = 100;
            if (ChanceNonSpawnbaseHasAA < 0) ChanceNonSpawnbaseHasAA = 0;
            if (RedMinAirfieldAA < 0) RedMinAirfieldAA = 0;
            if (BlueMinAirfieldAA < 0) BlueMinAirfieldAA = 0;
            if (RedMaxAirfieldAA < RedMinAirfieldAA) RedMaxAirfieldAA = RedMinAirfieldAA;
            if (BlueMaxAirfieldAA < BlueMinAirfieldAA) BlueMaxAirfieldAA = BlueMinAirfieldAA;
    
            int staticno = 0;
            ISectionFile f = GamePlay.gpCreateSectionFile();
    
            foreach (AiAirport TargetAirport in GamePlay.gpAirports())      // loop through all map airfields
            {
                Point2d port = new Point2d();       // remember the airfield position
                port.x = TargetAirport.Pos().x;
                port.y = TargetAirport.Pos().y;
    
                if (IsInBattleZone(port))                                       // is airfield inside the battle zone grid?
                {
                    Point2d AApos = new Point2d();                              // create a point for the AA position
                    int AirportArmy = GetArmyAtPoint(port.x, port.y);           // remember the airport army
                    if (AirportArmy == 0) AirportArmy = TargetAirport.Army();   // remember the airport army
    
                    // ------------------------------------------------------------------------------------------------
                    // ALLIED ARMY SPAWN BASES
                    // ------------------------------------------------------------------------------------------------
                    if (AirportArmy == 1 && IsBirthplace(TargetAirport))        // airfield is allied army & a spawn point
                    {
                        if (random.Next(100) < ChanceSpawnbaseHasAA)            // chance a spawn airfield has AA defences
                        {
                            int i = random.Next(RedMinAirfieldAA, RedMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                            for (int j = 0; j < i; j++)
                            {
                                // find a suitable AA position close to, but just outside, the airfield perimeter
                                AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                {
                                    AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                };
    
                                // make a new unique static object number for mission file
                                staticno++;
                                if (j == 0)
                                {   // at least one black flak unit
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[0] + " " +
                                        AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                }
                                else
                                {
                                    int rnd = random.Next(AlliedAA.Count);
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[rnd] + " " +
                                        AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                }
                            }
                        }
                    }
    
                    // ------------------------------------------------------------------------------------------------
                    // AXIS ARMY SPAWN BASES
                    // ------------------------------------------------------------------------------------------------
                    if (AirportArmy == 2 && IsBirthplace(TargetAirport))   // airfield is axis army & a spawn point
                    {
                        if (random.Next(100) < ChanceSpawnbaseHasAA)            // chance a spawn airfield has AA defences
                        {
                            int i = random.Next(BlueMinAirfieldAA, BlueMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                            for (int j = 0; j < i; j++)
                            {
                                // find a suitable AA position close to, but just outside, the airfield perimeter
                                AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                {
                                    AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                };
    
                                // make a new unique static object number for mission file
                                staticno++;
                                if (j == 0)
                                {   // at least one black flak unit
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), "Artillery.20_mm_Flak_38 de " + AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                }
                                else
                                {
                                    int rnd = random.Next(AxisAA.Count);
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AxisAA[rnd] + " " +
                                    AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                }
                            }
                        }
    
                        if (!SpawnBasesAAOnly)      // do we also want AA units at non-spawn bases?
                        {
                            // ------------------------------------------------------------------------------------------------
                            // ALLIED ARMY NON-SPAWN BASES
                            // ------------------------------------------------------------------------------------------------
                            if (AirportArmy == 1 && !IsBirthplace(TargetAirport))   // airfield is allied army & NOT a spawn point
                            {
                                if (random.Next(100) < ChanceNonSpawnbaseHasAA)     // chance a non-spawn airfield has AA defences
                                {
                                    int i = random.Next(RedMinAirfieldAA, RedMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                                    for (int j = 0; j < i; j++)
                                    {
                                        // find a suitable AA position close to, but just outside, the airfield perimeter
                                        AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                        {
                                            AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        };
    
                                        // make a new unique static object number for mission file
                                        staticno++;
                                        if (j == 0)
                                        {   // at least one black flak unit
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[0] + " " +
                                                AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
    
                                            Point3d p;
                                            p.x = AApos.x;
                                            p.y = AApos.y;
                                            p.z = 0;
                                        }
                                        else
                                        {
                                            int rnd = random.Next(AlliedAA.Count);
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[rnd] + " " +
                                                AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                        }
                                    }
                                }
                            }
    
                            if (AirportArmy == 2 && !IsBirthplace(TargetAirport))  // airfield is axis army & NOT a spawn point
                            {
                                // ------------------------------------------------------------------------------------------------
                                // AXIS ARMY NON-SPAWN BASES
                                // ------------------------------------------------------------------------------------------------
                                if (random.Next(100) < ChanceNonSpawnbaseHasAA)     // chance a non-spawn airfield has AA defences
                                {
                                    int i = random.Next(BlueMinAirfieldAA, BlueMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                                    for (int j = 0; j < i; j++)
                                    {
                                        // find a suitable AA position close to, but just outside, the airfield perimeter
                                        AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                        {
                                            AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        };
    
                                        // make a new unique static object number for mission file
                                        staticno++;
                                        if (j == 0)
                                        {   // at least one black flak unit
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), "Artillery.20_mm_Flak_38 de " + AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                        }
                                        else
                                        {
                                            int rnd = random.Next(AxisAA.Count);
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AxisAA[rnd] + " " +
                                            AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {   // write an error message to the concole
                        //Console.WriteLine("CAUTION: Could not spawn AA at " + TargetAirport.Name() + "(army=" + AirportArmy.ToString() + ") [GenerateRandomAAatAirfields]");
                    }
                }
            }
    
            GamePlay.gpPostMissionLoad(f);                              // load the mission with the AA units
        }
         
        public bool IsBirthplace(AiAirport airfield)
        {
            bool result = false;
            foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
            {
                Point3d p = bp.Pos();
                if (airfield.Pos().distance(ref p) <= airfield.CoverageR() || airfield.Pos().distance(ref p) <= airfield.FieldR())
                {
                    result = true;
                }
            }
            return result;
        }
    
        public bool IsInBattleZone(Point2d p)
        {   // returns true if specified point is inside the battle zone grid
            bool result = false;
            string sector = GamePlay.gpSectorName(p.x, p.y);        // get the sector at the specified point
            string[] words = sector.Split(',');                     // break up the sector name
            string axis1 = words[0];                                // first part is X axis
            string axis2 = words[1];                                // second part is Y axis
            // is it inside the battle grid?
            if (Regex.IsMatch(axis1, @"^[a-zA-Z0-9]+$") && Regex.IsMatch(axis2, @"^[a-zA-Z0-9]+$")) result = true;
            return result;
        }
    
        public bool IsInvalidAAposition(Point2d point, double radius)
        {
            bool result = false;
            Point3d p = new Point3d();
            p.x = point.x;
            p.y = point.y;
            p.z = 0;
    
            // too close to other ground units
            try
            {
                foreach (GroundStationary gs in GamePlay.gpGroundStationarys())
                {
                   if (gs.pos.distance(ref p) <= radius) result = true;
                }
            }
            catch { }
    
            // wrong terrain
            if (GamePlay.gpLandType(point.x, point.y) == LandTypes.RAIL || GamePlay.gpLandType(point.x, point.y) == LandTypes.ROAD ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.WATER || GamePlay.gpLandType(point.x, point.y) == LandTypes.OBJECTS_MASK ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.ROAD_MASK || GamePlay.gpLandType(point.x, point.y) == LandTypes.HIGHWAY ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.CITY) result = true;
    
            // outside the battle zone?
            if (!IsInBattleZone(point)) result = true;
    
            return result;
    		}
    		catch { return true; }
    	}
    	
    	public int GetArmyAtPoint(double x, double y)
    	{
    		int result = 0;
    		result = GamePlay.gpFrontArmy(x, y);
    		return result;
    	}
    
    	public Point2d GetRandomPointInsideCircle(double x, double y, double r)
    	{   // return a random 2d point inside circle with center x, y and radius r (meters)
    		Point2d p = new Point2d();
    		p.x = x + r * Math.Cos(random.Next());
    		p.y = y + r * Math.Sin(random.Next());
    		return p;
    	}
    }

  22. Likes GANIX liked this post
  23. #18
    Combat pilot
    Join Date
    Oct 2021
    Posts
    113
    Post Thanks / Like
    Total Downloaded
    12.95 MB

    Re: TWC Dogfight PvP

    Hello BlacKnight,

    thank you for sharing your developments. The more we share, the more we get.

    Could it be that the code causes a 'curly-bracket-error' in line 261?
    Last edited by GANIX; Dec-13-2022 at 03:43.

  24. #19
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: TWC Dogfight PvP

    Try this

    Code:
    using System.Text;
    using System;
    using System.Collections;
    using maddox.game;
    using maddox.game.world;
    using part;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Threading;
    using System.Runtime.InteropServices;
    using System.Globalization;
    using System.Reflection;
    using maddox.GP;
    using System.Text.RegularExpressions;
    
    
    public class Mission : AMission
    {
        Random random = new Random();
    
        // random AA on battle startup (generate random AA at airfields on battle start)
        bool GenerateRandomAA = true;               // turn random AA at airfields on/off
        bool SpawnBasesAAOnly = false;              // random AA generated at spawn airfields only
        int ChanceSpawnbaseHasAA = 100;             // percent chance a spawn base has AA defences
        int ChanceNonSpawnbaseHasAA = 0;           // percent chance a non-spawn base has AA defences
        int RedMinAirfieldAA = 10;                   // minimum number of AA units at red airfields
        int RedMaxAirfieldAA = 12;                   // maximum number of AA units at red airfields
        int BlueMinAirfieldAA = 10;                  // minimum number of AA units at blue airfields
        int BlueMaxAirfieldAA = 12;                  // maximum number of AA units at blue airfields
    
        public override void OnBattleStarted()
        {
            base.OnBattleStarted();
            if (GenerateRandomAA ) GenerateRandomAAatAirfields();
        }
    
        public void GenerateRandomAAatAirfields()
        {   // spawn random AA at airfields
            List<string> AlliedAA = new List<string>
            {
                "Artillery.3_inch_20_CWT_QF_Mk_I gb",
                "Artillery.3_7_inch_QF_Mk_I gb",
                "Artillery.Bofors gb",
                "Artillery.20_mm_Flak_38 gb"
            };
    
            List<string> AxisAA = new List<string>
            {
                "Artillery.Flak30_Shield de",
                "Artillery.Flak37 de",
                "Artillery.20_mm_Flak_38 de",
                "Artillery.Zwillingssockel36_GER1 de",
                "Artillery.4_cm_Flak_28 de"
            };
    
            // do some parameter intergity checks
            if (ChanceSpawnbaseHasAA > 100) ChanceSpawnbaseHasAA = 100;
            if (ChanceSpawnbaseHasAA < 0) ChanceSpawnbaseHasAA = 0;
            if (ChanceNonSpawnbaseHasAA > 100) ChanceNonSpawnbaseHasAA = 100;
            if (ChanceNonSpawnbaseHasAA < 0) ChanceNonSpawnbaseHasAA = 0;
            if (RedMinAirfieldAA < 0) RedMinAirfieldAA = 0;
            if (BlueMinAirfieldAA < 0) BlueMinAirfieldAA = 0;
            if (RedMaxAirfieldAA < RedMinAirfieldAA) RedMaxAirfieldAA = RedMinAirfieldAA;
            if (BlueMaxAirfieldAA < BlueMinAirfieldAA) BlueMaxAirfieldAA = BlueMinAirfieldAA;
    
            int staticno = 0;
            ISectionFile f = GamePlay.gpCreateSectionFile();
    
            foreach (AiAirport TargetAirport in GamePlay.gpAirports())      // loop through all map airfields
            {
                Point2d port = new Point2d();       // remember the airfield position
                port.x = TargetAirport.Pos().x;
                port.y = TargetAirport.Pos().y;
    
                if (IsInBattleZone(port))                                       // is airfield inside the battle zone grid?
                {
                    Point2d AApos = new Point2d();                              // create a point for the AA position
                    int AirportArmy = GetArmyAtPoint(port.x, port.y);           // remember the airport army
                    if (AirportArmy == 0) AirportArmy = TargetAirport.Army();   // remember the airport army
    
                    // ------------------------------------------------------------------------------------------------
                    // ALLIED ARMY SPAWN BASES
                    // ------------------------------------------------------------------------------------------------
                    if (AirportArmy == 1 && IsBirthplace(TargetAirport))        // airfield is allied army & a spawn point
                    {
                        if (random.Next(100) < ChanceSpawnbaseHasAA)            // chance a spawn airfield has AA defences
                        {
                            int i = random.Next(RedMinAirfieldAA, RedMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                            for (int j = 0; j < i; j++)
                            {
                                // find a suitable AA position close to, but just outside, the airfield perimeter
                                AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                {
                                    AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                };
    
                                // make a new unique static object number for mission file
                                staticno++;
                                if (j == 0)
                                {   // at least one black flak unit
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[0] + " " +
                                        AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                }
                                else
                                {
                                    int rnd = random.Next(AlliedAA.Count);
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[rnd] + " " +
                                        AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                }
                            }
                        }
                    }
    
                    // ------------------------------------------------------------------------------------------------
                    // AXIS ARMY SPAWN BASES
                    // ------------------------------------------------------------------------------------------------
                    if (AirportArmy == 2 && IsBirthplace(TargetAirport))   // airfield is axis army & a spawn point
                    {
                        if (random.Next(100) < ChanceSpawnbaseHasAA)            // chance a spawn airfield has AA defences
                        {
                            int i = random.Next(BlueMinAirfieldAA, BlueMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                            for (int j = 0; j < i; j++)
                            {
                                // find a suitable AA position close to, but just outside, the airfield perimeter
                                AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                {
                                    AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                };
    
                                // make a new unique static object number for mission file
                                staticno++;
                                if (j == 0)
                                {   // at least one black flak unit
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), "Artillery.20_mm_Flak_38 de " + AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                }
                                else
                                {
                                    int rnd = random.Next(AxisAA.Count);
                                    f.add("Stationary", "Static" + staticno.ToString("0000"), AxisAA[rnd] + " " +
                                    AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                }
                            }
                        }
    
                        if (!SpawnBasesAAOnly)      // do we also want AA units at non-spawn bases?
                        {
                            // ------------------------------------------------------------------------------------------------
                            // ALLIED ARMY NON-SPAWN BASES
                            // ------------------------------------------------------------------------------------------------
                            if (AirportArmy == 1 && !IsBirthplace(TargetAirport))   // airfield is allied army & NOT a spawn point
                            {
                                if (random.Next(100) < ChanceNonSpawnbaseHasAA)     // chance a non-spawn airfield has AA defences
                                {
                                    int i = random.Next(RedMinAirfieldAA, RedMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                                    for (int j = 0; j < i; j++)
                                    {
                                        // find a suitable AA position close to, but just outside, the airfield perimeter
                                        AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                        {
                                            AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        };
    
                                        // make a new unique static object number for mission file
                                        staticno++;
                                        if (j == 0)
                                        {   // at least one black flak unit
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[0] + " " +
                                                AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
    
                                            Point3d p;
                                            p.x = AApos.x;
                                            p.y = AApos.y;
                                            p.z = 0;
                                        }
                                        else
                                        {
                                            int rnd = random.Next(AlliedAA.Count);
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AlliedAA[rnd] + " " +
                                                AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0/skill 1");
                                        }
                                    }
                                }
                            }
    
                            if (AirportArmy == 2 && !IsBirthplace(TargetAirport))  // airfield is axis army & NOT a spawn point
                            {
                                // ------------------------------------------------------------------------------------------------
                                // AXIS ARMY NON-SPAWN BASES
                                // ------------------------------------------------------------------------------------------------
                                if (random.Next(100) < ChanceNonSpawnbaseHasAA)     // chance a non-spawn airfield has AA defences
                                {
                                    int i = random.Next(BlueMinAirfieldAA, BlueMaxAirfieldAA + 1);    // decide how many AA units to spawn at the airfield
                                    for (int j = 0; j < i; j++)
                                    {
                                        // find a suitable AA position close to, but just outside, the airfield perimeter
                                        AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        while (port.distance(ref AApos) < (TargetAirport.FieldR() * 0.95) || IsInvalidAAposition(AApos, 100))
                                        {
                                            AApos = GetRandomPointInsideCircle(TargetAirport.Pos().x, TargetAirport.Pos().y, TargetAirport.FieldR() * 0.70 * 1.25);
                                        };
    
                                        // make a new unique static object number for mission file
                                        staticno++;
                                        if (j == 0)
                                        {   // at least one black flak unit
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), "Artillery.20_mm_Flak_38 de " + AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                        }
                                        else
                                        {
                                            int rnd = random.Next(AxisAA.Count);
                                            f.add("Stationary", "Static" + staticno.ToString("0000"), AxisAA[rnd] + " " +
                                            AApos.x.ToString() + " " + AApos.y.ToString() + " " + random.Next(1, 178 + 1).ToString() + " /timeout 0/radius_hide 0");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {   // write an error message to the concole
                        //Console.WriteLine("CAUTION: Could not spawn AA at " + TargetAirport.Name() + "(army=" + AirportArmy.ToString() + ") [GenerateRandomAAatAirfields]");
                    }
                }
            }
    
            GamePlay.gpPostMissionLoad(f);                              // load the mission with the AA units
        }
         
        public bool IsBirthplace(AiAirport airfield)
        {
            bool result = false;
            foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
            {
                Point3d p = bp.Pos();
                if (airfield.Pos().distance(ref p) <= airfield.CoverageR() || airfield.Pos().distance(ref p) <= airfield.FieldR())
                {
                    result = true;
                }
            }
            return result;
        }
    
        public bool IsInBattleZone(Point2d p)
        {   // returns true if specified point is inside the battle zone grid
            bool result = false;
            string sector = GamePlay.gpSectorName(p.x, p.y);        // get the sector at the specified point
            string[] words = sector.Split(',');                     // break up the sector name
            string axis1 = words[0];                                // first part is X axis
            string axis2 = words[1];                                // second part is Y axis
            // is it inside the battle grid?
            if (Regex.IsMatch(axis1, @"^[a-zA-Z0-9]+$") && Regex.IsMatch(axis2, @"^[a-zA-Z0-9]+$")) result = true;
            return result;
        }
    
        public bool IsInvalidAAposition(Point2d point, double radius)
        {
            bool result = false;
            Point3d p = new Point3d();
            p.x = point.x;
            p.y = point.y;
            p.z = 0;
    
            // too close to other ground units
            try
            {
                foreach (GroundStationary gs in GamePlay.gpGroundStationarys())
                {
                   if (gs.pos.distance(ref p) <= radius) result = true;
                }
            }
            catch { }
    
            // wrong terrain
            if (GamePlay.gpLandType(point.x, point.y) == LandTypes.RAIL || GamePlay.gpLandType(point.x, point.y) == LandTypes.ROAD ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.WATER || GamePlay.gpLandType(point.x, point.y) == LandTypes.OBJECTS_MASK ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.ROAD_MASK || GamePlay.gpLandType(point.x, point.y) == LandTypes.HIGHWAY ||
                GamePlay.gpLandType(point.x, point.y) == LandTypes.CITY) result = true;
    
            // outside the battle zone?
            if (!IsInBattleZone(point)) result = true;
    
            return result;
    	}
    	
    	public int GetArmyAtPoint(double x, double y)
    	{
    		int result = 0;
    		result = GamePlay.gpFrontArmy(x, y);
    		return result;
    	}
    
    	public Point2d GetRandomPointInsideCircle(double x, double y, double r)
    	{   // return a random 2d point inside circle with center x, y and radius r (meters)
    		Point2d p = new Point2d();
    		p.x = x + r * Math.Cos(random.Next());
    		p.y = y + r * Math.Sin(random.Next());
    		return p;
    	}
    }

  25. Likes GANIX liked this post
  26. #20
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    I will drop it in today and work on it before the weekend. I need to get the airfields populated in Tobruk so that is why I pulled till this weekend. Hope to see more this weekend either dog fighting or in operation theater. Anyway, Oskar thanks for your support got everything working within the code right now, still tweaking the AI.

    Looking for a diorama JUNKY for Airfield static objects! PLEASE contact me in private messages.

    BlacKnight

  27. #21
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: TWC Dogfight PvP

    Oskar is there any way to get the plane count at the airfield on the map showing how many pilots are at the airbase. So, when people join, they see what airfield pilots are populating.


    Not sure if it is possible.

  28. #22
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: TWC Dogfight PvP

    I can't think of any way to do that.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •