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)
-   -   Online War - FMB scripting (http://forum.fulqrumpublishing.com/showthread.php?t=21518)

ZaltysZ 05-24-2011 03:09 PM

"active" is boolean (logical true or false). You should check "active" to see if trigger is active.

Code:

if (shortName.Equals("attackConvoyDelay") && active)
means: if trigger name is "attackConvoyDelay" AND (&&) this trigger is active, then do something...

klem 05-24-2011 03:54 PM

Aaahh! Got it. Thanks

Ataros 05-24-2011 07:41 PM

Quote:

Originally Posted by TheEnlightenedFlorist (Post 285151)

This code will loop through all BirthPlaces and print a message to the screen if a BirthPlace is on the opposite side of the front line.

Code:

foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
        {
            if (GamePlay.gpFrontArmy(bp.Pos().x, bp.Pos().y) != bp.Army())
                GamePlay.gpHUDLogCenter("Front and BirthPlace do not match!");
        }

I'm having fun. :)

Getting back to moving frontline.
Does GamePlay.gpFrontArmy(bp.Pos().x, bp.Pos().y) work at any point of map or only at frontline/border?

Where can I see the complete list of such commands/functions like GamePlay.gpFrontArmy(bp.Pos().x, bp.Pos().y)? Should I add some game files to my project in Visual Studio? Till now I only opened separate .cs files with it.

TheEnlightenedFlorist 05-24-2011 11:18 PM

Quote:

Originally Posted by Ataros (Post 288356)
Getting back to moving frontline.
Does GamePlay.gpFrontArmy(bp.Pos().x, bp.Pos().y) work at any point of map or only at frontline/border?

Where can I see the complete list of such commands/functions like GamePlay.gpFrontArmy(bp.Pos().x, bp.Pos().y)? Should I add some game files to my project in Visual Studio? Till now I only opened separate .cs files with it.

Yes, it should work for any point on the map.

Visual Studio will let you see all of the methods in roundabout way. Try this:

1. File >> New >> Project Type in a name and solution name at the bottom. Don't worry about what kind of project you create.

2. On the right side under "Solution Explorer", right click on "References", "Add Reference..."

3. Click on the "Browse" tab, navigate to "Steam/steamapps/common/il-2 sturmovik cliffs of dover/parts/core"

4. Go through each .dll file in that list and try to add it. Some will give you an error, just skip those.

After you've added all the .dll files, right click on the name of your project and do "Add Existing Item". Find one of your script files and add it. Now Visual Studio will show you all the possible methods as you're typing your code. You can also go to View >> Object Browser and have a look in there.

Important: When you import an existing item, Visual Studio makes a copy of the file so any changes you make won't be reflected in the original file, you'll have to copy the new one over it. If anybody knows how to change this, I'd be quite grateful.

Ataros 05-25-2011 07:34 AM

Thanks a lot for detailed explanation.

BTW did you see the scripting in this mission from the devs http://forum.1cpublishing.eu/showpos...&postcount=133

I was reading it yesterday and it just blows my mind away. There are some great pieces everyone should use:

- airfield capture with removal of old arty
- generating triggers names with variables (string str = "changeArmy" + i.ToString() + "_" + (j).ToString();)
- generating waypoints for bombers to attack the most close ground target
- scoring system
etc.

I'll try to convert this mission to the Channel map when I have time. Probably will need a lot of help on C# ))

Devs confirmed that there is a bug not allowing to use captured airfields before switching sides. They are working on it.

TheEnlightenedFlorist 05-25-2011 07:51 AM

Quote:

Originally Posted by Ataros (Post 288595)
Devs confirmed that there is a bug not allowing to use captured airfields before switching sides. They are working on it.

Cool. All of this would be in vain otherwise.:grin:

I've only glanced at that mission, but I've already learned a few things that will make things easier.

klem 05-25-2011 07:57 AM

I'm having trouble giving messages to a particular side under OnTickGame because I don't know how to find out which side I am on (" 'aircraft' is not valid in this context"). Any ideas please?

Code:

public override void OnTickGame()

      {

          if (Time.tickCounter() % 115200 == 1980) // Testing, reduced to 1 min. 1980 = 60secs delay.
          {
                GamePlay.gpHUDLogCenter("1 minute Timetick message.");
              //issue message after further 30 seconds (test)
                double initTime = 0.0;
                Timeout(initTime += 30, () =>
                    if (aircraft != null)    //error the name aircraft does not exist in the current context
                          {
                          switch (aircraft.Army())                          {               
                                case 1:
                              { GamePlay.gpHUDLogCenter("Red side message."); }
                                break;
                                case 2:
                              { GamePlay.gpHUDLogCenter("Blue side message"); }             
                            break;
                              }
                    });
          }

      }


hc_wolf 06-18-2011 04:23 AM

I converted the Dynamic campaign onto the Channel map. Works great.
 
I am trying to build a Falcon 4 type game where Germans advance towards cahnnel and English must drive them back.

SNAFU 06-21-2011 12:48 PM

Hi all, and sorry Klem, I can´t help you...:(

I started now with my attempt to get familar with scripting and C#... :-P:rolleyes:

I read through this thread a several times and copied some samples of the outlined scripts.

The problem at hand now, is that I want to include a script in the submissions, which will be loaded into a main, basic-map. This submission script shall contain

Sec 1- the trigger messages,

Sec 2-the instruction messages for new players and players which just took off (WIP:Message shall only be shown, if trigger is not activated yet)

Sec 3- a count of trigger states, so very time a victory-trigger is set to true a counter raises the number for the side, which activated the trigger

Sec 4- clean up procedure at a certain time from begin of submission, removing all AI loaded into the basic map with the submission

Following questions appeared now at this stage:

(A) I already found out how to theoretically get the trigger messages running, still have to get it right, how to show the message only if the otherside (red/blue) has not activated their trigger yet.
Is thiss possible by something like this?

if (<Trigger Red won> == active || <Trigger Blue won> == acitve)
<message red won>


(B) How do I get rid off of all the AI loaded on the basic map, when the submission has done its job?

I wanted to try following script sample to remove the AI after an hour into the submission:

//////////////// Section 4: get rid off all AI loaded with submission

//mod-start by SNAFU -> ZIEL: nach 1h AI-Flieger entfernen

public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 108000 == 10799) // 108000=1h
{
//mod-end by SNAFU

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) /// <- delete line to kill all
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiAircraft).Destroy();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) /// <- delete line to kill all
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiGroundActor).Destroy();
}
}
}
}
}


(C) I now loaded a briefing message into the basic map, so every player joining and taking off, will be briefed into the actual ongoing submission. The basic map listens to all events introduced with the submissions, ok. But...

If the the submission is over, how does the main script notice the that the submissions states, messages (f.e. the briefing messages) are not valid anymore? Ist that the "puplic override" I see everywhere?

Here the template for the submission script and sorry for all the silly questions: :rolleyes:
Code:

using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission

//////////////////////////////////////////////////////////////////////////////////////
///////////Section 1: Trigger messages

///to copy into

/////////////////////////////////////////////////Section 3: Briefing for new players

///WIP                if (<Trigger missions success red/blue> = false) /////WIP: Trigger Condition for Mission red/blue != true

{
        public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);
        AiAircraft aircraft = actor as AiAircraft;
       
        if (aircraft != null)
        switch (aircraft.Army())
                {               
            case 1:
                if (aircraft.Type() == AircraftType.Bomber)                                /////////////Nachricht für neue Spieler
                { GamePlay.gpHUDLogCenter(new Player[] {player},"Red Bomber Task"); }                /////////roter Bomber
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Red Fighter Task"); }        ///////////roter Jäger
                break;
            case 2:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { player }, "Blue Bomber Task"); }                ////////////blauer Bomber
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Blue Fighter Task"); }            //////////// blauer Jäger
                break;

                }
    }

            public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftTookOff(missionNumber, shortName, aircraft);

        if (GamePlay.gpPlayer().Place() != aircraft)
            return;
       
        switch (aircraft.Army())
                {
            case 1:
              if (aircraft.Type() == AircraftType.Bomber)                                                        /////////////Nachricht für neue Spieler
                { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber Task"); }                        /////////roter Bomber
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Fighter Task"); }                ///////////roter Jäger
              break;
            case 2:
                if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber))
              { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Blue Bomber Task"); }                      ////////////blauer Bomber
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber Task"); }                //////////// blauer Jäger
              break;

                }
    }

///WIP }

//////////////////////////////////////////////////////////////////////////////////////
//////////////// Section 3: Trigger count for overall win condition


// still no idea


//////////////////////////////////////////////////////////////////////////////////////
//////////////// Section 4: get rid off all AI loaded with submission

//mod-start by SNAFU -> ZIEL: nach 1h AI-Flieger entfernen

public override void OnTickGame()
{
  double initTime;   

    if (Time.tickCounter() % 108000 == 10799) // 108000=1h
  {
//mod-end by SNAFU

foreach (int army in GamePlay.gpArmies())
            {
                foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
                {
                    if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber)) /// <- delete line to kill all
                    {
                        AiActor[] members = group.GetItems();
                        for (int i = members.Length - 1; i > -1; i--)
                        {
                            (members[i] as AiAircraft).Destroy();
                        }
                    }
                }
                foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
                {
                    if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber)) /// <- delete line to kill all
                    {
                        AiActor[] members = group.GetItems();
                        for (int i = members.Length - 1; i > -1; i--)
                        {
                            (members[i] as AiGroundActor).Destroy();
                        }
                    }
                }
            }
}



All times are GMT. The time now is 05:47 PM.

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