Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   Script assistance needed (http://forum.fulqrumpublishing.com/showthread.php?t=26036)

ATAG_Bliss 09-09-2011 09:02 PM

Script assistance needed
 
I'm trying to find a way to limit human controlled plane types (spit, hurri, 109 etc.) to a certain amount. Say I only want to have 4 spitIIa's or 4 110C7's, would anyone know how to do this?

I know with FBDj of old, it was simple. Say a map that had a 262 in it, you could limit them to 2 (for example) and only 2 could ever be spawned in game at once (aka - only 2 possible at all times throughout the mission). Any more than 2 and the selection would simply be greyed out or not selectable.

Any chance someone has found a way to do this with IL2COD yet?

Would be much appreciated.

Thanks!

Ataros 09-10-2011 08:28 AM

This mission has a script limiting number of aircraft by type. http://forum.1cpublishing.eu/showthr...eration+dynamo
If you make it working please share the final script to add to community knowledge base. I asked several times but never have seen scripts Syndicate or ATAG is running :) C'mon you are nice guys :) Let's make the CloD world better by sharing knowledge.

ATAG_Bliss 09-10-2011 02:28 PM

Hi Ataros - Thanks :)

I'll take a look at that and see if I can't get something to work. As far as the scripts are concerned, there's nothing special lol. The knowledge all came from you guys. I just know how to copy/paste to fine tune!

But I use a combination of .cmd files (using f to load and timeout command to recycle the mission) and C# to be able to make the scripts work 24/7.

Here's the scripts for the main and submission:

Code:

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
 
public class Mission : AMission
{
    public override void OnBattleStarted()
    {
        base.OnBattleStarted();
 
        //listen to events from all missions.
        MissionNumberListener = -1;
    }
 
    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        Timeout(1, () =>
        { damageAiControlledPlane(actor); }
            );
    }
 
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(300, () =>
        { destroyPlane(aircraft); }
            );
    }
    public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftLanded(missionNumber, shortName, aircraft);
        Timeout(300, () =>
        { destroyPlane(aircraft); }
            );
    }
 
    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)
            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(300, () =>
            { destroyPlane(aircraft); }
                );
        }

    }
       
}

submissions

Code:

using System;
using maddox.game;
using maddox.game.world;

public class Mission : maddox.game.AMission
{
   
    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
      base.OnTrigger(missionNumber, shortName, active);

          if ("SpawnAirgroup1".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup1");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("BR.20M's enroute to Hawkinge");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
                  if ("SpawnAirgroup5".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup5");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Blenheims enroute to Coquelles");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
   
       

          if ("SpawnAirgroup2".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup2");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Stukas enroute to Hawkinge");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
                          if ("SpawnAirgroup6".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup6");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Wellingtons enroute to Caffiers");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
     
                if ("SpawnAirgroup3".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup3");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("He 111s enroute to Lympne");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
                  if ("SpawnAirgroup7".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup7");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Wellingtons enroute to Pihen Airfield");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
                  if ("SpawnAirgroup4".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup4");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Ju 88's enroute to Hawkinge");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
                  if ("SpawnAirgroup8".Equals(shortName) && active)
          {
                AiAction action = GamePlay.gpGetAction("Airgroup8");
                if (action != null)
                {
                    action.Do();
                }
                GamePlay.gpHUDLogCenter("Wellingtons enroute to St. Inglevert");     
                GamePlay.gpGetTrigger(shortName).Enable = false;           
          }
    }
}

As you can see there's nothing special ;)

Ataros 09-10-2011 06:49 PM

Thank you very much for sharing! I hope many new servers which want to be as popular as ATAG can benefit from this to the benefit of CloD community in general.

S!

ATAG_Bliss 09-10-2011 08:43 PM

No problem Ataros!

Question (maybe for another topic) but how do you have 3 servers all running off of the same machine? We are using about 10% of the power of our machine with only running one server, and we'd like to have 3 different servers up as well.

Thanks,
Bliss

Ataros 09-11-2011 08:19 AM

Quote:

Originally Posted by ATAG_Bliss (Post 334539)
No problem Ataros!

Question (maybe for another topic) but how do you have 3 servers all running off of the same machine? We are using about 10% of the power of our machine with only running one server, and we'd like to have 3 different servers up as well.

Thanks,
Bliss

BigRepa, server owner, runs 3 virtual PCs on one hardware using VMWare i believe. There was a screenshot of VMWare settings in Repka thread. Now he switched to desktop OS like Win7 or Vista for compatibility with some missions and the limitation is each OS can use only 2 cores of his 6-core AMD. With server OS there is no such a limitation probably.
Virtual machines are needed because you can not run 3 Steam accounts in one OS at the same time.

I think you can easily run 4 or 6 servers on your hardware. Also have a look at server automation link in my sig to make running several servers easier.

Ze-Jamz 09-11-2011 11:11 AM

~S~ Bliss

Have you seen the script being wrote for the bailout/Ai/create situation, everyone shooting down AI which is getting irritating?

ATAG_Bliss 09-13-2011 09:36 PM

Quote:

Originally Posted by Ataros (Post 334666)
BigRepa, server owner, runs 3 virtual PCs on one hardware using VMWare i believe. There was a screenshot of VMWare settings in Repka thread. Now he switched to desktop OS like Win7 or Vista for compatibility with some missions and the limitation is each OS can use only 2 cores of his 6-core AMD. With server OS there is no such a limitation probably.
Virtual machines are needed because you can not run 3 Steam accounts in one OS at the same time.

I think you can easily run 4 or 6 servers on your hardware. Also have a look at server automation link in my sig to make running several servers easier.

Thanks :)

I'll try to see what I can come up with.

Quote:

Originally Posted by Ze-Jamz (Post 334717)
~S~ Bliss

Have you seen the script being wrote for the bailout/Ai/create situation, everyone shooting down AI which is getting irritating?

Yeah.. It's a good idea. Hopefully, when I get some time, I'll try to incorporate in.

klem 09-21-2011 08:05 AM

Quote:

Originally Posted by Ataros (Post 334262)
This mission has a script limiting number of aircraft by type. http://forum.1cpublishing.eu/showthr...eration+dynamo
If you make it working please share the final script to add to community knowledge base. I asked several times but never have seen scripts Syndicate or ATAG is running :) C'mon you are nice guys :) Let's make the CloD world better by sharing knowledge.

Thats what I said. We could do with our own Library. Might help those of us struggling to build missions:-

http://forum.1cpublishing.eu/showthread.php?t=26292

Gamekeeper 09-21-2011 10:41 PM

Quote:

Originally Posted by klem (Post 338958)
Thats what I said. We could do with our own Library. Might help those of us struggling to build missions:-

http://forum.1cpublishing.eu/showthread.php?t=26292

My offer to assist and host as mentioned in the above thread is still open. Unfortunately there seems to be little interest so far.


All times are GMT. The time now is 02:23 AM.

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