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-16-2011, 04:45 PM
David198502's Avatar
David198502 David198502 is offline
Approved Member
 
Join Date: Dec 2009
Location: Austria
Posts: 1,536
Default

there it is...
Attached Files
File Type: txt totalwar.txt (4.8 KB, 10 views)
__________________
Reply With Quote
  #2  
Old 10-16-2011, 05:39 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Ok, i see couldn't work

this is the main block:

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

public class Mission : AMission
{


}
You must place your code between the two brackets { ... }

so you must place
public override void OnActorCreated(....)
{
.....
.....
}

and
public override void OnTickGame(...)
{
.....
.....
}
between the brackets.
Your fault was that you placed the OnActorCreated into the OntickGame and this is not allowed in C#.
Hint: Open your Clod Console and you will see error messages if anything goes wrong.

So should your code look like:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

    public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorCreated(missionNumber, shortName, actor);

        if (actor is AiAircraft)
        {
            switch ((actor as AiAircraft).InternalTypeName())
            {

                case "bob:Aircraft.He-111P-2":

                    Timeout(600, () =>    // Time in Seconds
                         {
                             (actor as AiAircraft).Destroy();
                         });
                    break;
            }
        }
    }




    public override void OnTickGame()
    {

        // loads the 1st sub-mission in 10 min and repeates it every 60 min.
        if (Time.tickCounter() % 10800 == 180) // 108000 = 60 min repeat. 1800 = 10 min delay. 
        // pls. note!!! the 1st figure above must be always larger than 2nd!
        {
            GamePlay.gpPostMissionLoad("missions/Single/mission1.mis");

            // prints message on screen after mission load
            GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");

            // prints message on screen in 10 minutes
            double initTime = 0.0;
            Timeout(initTime += 600, () =>
            {
                GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
            });

            // prints message on screen in 5 minutes
            Timeout(initTime += 300, () =>
            {
                GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
            });

        }

        // loads the 2nd sub-mission, etc. the same way
        if (Time.tickCounter() % 10800 == 1000) //  108000 = 60 min repeat, 54000 = 30 min delay. 
        {
            GamePlay.gpPostMissionLoad("missions/Single/mission2.mis");
            GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
            double initTime = 0.0;
            Timeout(initTime += 600, () =>
             {
                 GamePlay.gpHUDLogCenter("Mission2 10 min message!");
             });

            Timeout(initTime += 300, () =>
               {
                   GamePlay.gpHUDLogCenter("Mission2 15 min message!");
               });
        }

        // loads the 3rd sub-mission
        if (Time.tickCounter() % 10800 == 2000) // 60 min repeat, 50 min delay 
        {
            GamePlay.gpPostMissionLoad("missions/Multi/Single/mission3.mis");
            GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

            double initTime = 0.0;
            Timeout(initTime += 600, () =>
            {
                GamePlay.gpHUDLogCenter("Mission3 10 min message!");
            });
            Timeout(initTime += 300, () =>
            {
                GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
            });
        }
    }
}
btw i've not tested the script in Clod so may be there are other errors are present, but normaly it should work.
Reply With Quote
  #3  
Old 10-16-2011, 06:32 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Very interesting thread. Thank you, Kodiak.

I guess spawning the same group OnTrigger again and again may not work because when the group spawns the 2nd time it belongs to the second mission, etc. The game engine includes mission counter as far as I understand from naryv's examples. I think a long_name of a group may include a mission (submission) number.

Maybe the way to load the same group OnTrigger is to make a sub-mission which includes both an airgroup and a trigger. Then load the same submission OnTrigger. Can not grasp it 100% myself, just thinking aloud.
Reply With Quote
  #4  
Old 10-17-2011, 09:29 AM
SNAFU SNAFU is offline
Approved Member
 
Join Date: Feb 2011
Posts: 324
Default

No, that works, but you have to clear the trigger again, after it was triggered.

If you have the following for the trigger:
Code:
 if (("RedIntercept1".Equals(shortName) && active) && (CountAIAirplanes(1) <= maxRedAI)) 
          { 
                AiAction action = GamePlay.gpGetAction("RedIntercept1");
                if (action != null)
			MissionTimer1Int.Restart();
			MissionTimer1IntA.Start();			
			GamePlay.gpLogServer(null, "Intercept 1 triggered ", new object[] { }); //Testmeldung
                {
                     action.Do();
                }
                GamePlay.gpGetTrigger(shortName).Enable = false;            
          }
You can clear the trigger again by something like this:
Code:
if (MissionTimer1IntA.Elapsed.Minutes >= 30)   			//wieder freischalten des Triggers
    {
	GamePlay.gpGetTrigger("RedIntercept1").Enable = true; 
	MissionTimer1IntA.Reset();					
	GamePlay.gpLogServer(null, "Trigger 1 clear", new object[] { }); 		//Testmeldung
	}
__________________
http://cornedebrouwer.nl/cf48e
Reply With Quote
  #5  
Old 10-17-2011, 01:11 PM
David198502's Avatar
David198502 David198502 is offline
Approved Member
 
Join Date: Dec 2009
Location: Austria
Posts: 1,536
Default

ok Kodiak...i tried the script.
the He's of the main mission disappear after the 60seconds, but all other He's of the submissions will stay on the map...

so i pasted the relevant part of the script in all the submissios to destroy these He's as well.....this works!

...but is it possible to edit the script of the main mission, that all He's, including the ones of the submissions, disappear?

i looked at your brilliant tutorials on sturmovik.de and saw that its possible to destroy planes not only after a certain time, but when they cross a certain waypoint...but honestly im a bit overwhelmed by all its details that i dont consider myself capable of doing this by myself....

i also saw that it is possible to load submissions randomly...but in your tutorial you have some conditions which determine whether a mission is loaded or not(mission x will not be loaded if one destroys friendly vehicle)...i would like to load submissions randomly, regardless of any conditions, every xx seconds.is that possible?

i think its a better solution for my purpose to load submissions by random than loading mission after mission in determined sequence, because this would add an surprising factor, and i think it would shorten the script drastically, if i want to have 20 or more submissions.


btw, i really appreciate your help, and admire your patience with me!thx in advance...




PHP Code:
/**** 
 * Brief startup guide to scripting. 
 * This is a sample script to create a small online 'campaign' containing a main mission and 3 sub-missions.
 * 
 * Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g. 
 * C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
 * Scripts have to be saved with .cs extension and have the same name as the main mission.
 * Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs.
 * Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder):
 * C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\ 
 * Create and edit 3 missions you want to be loaded into the main mission with FMB.
 * Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis.
 * That's it.
 * 
 * In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , than edit 3 filepaths in this file. 
 * e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission.  * 
 * 
 * Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map).
 * The text in this example is visible to both sides for simplicity.
 * 
 * You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand.
 * Download link http://www.microsoft.com/express/Downloads/#2010-Visual-CS
 * 
 * All text after // marks are comments describing what the script does.
 * You may play your mission in MP or as a SP mission if you create a passworded server.
 * Have fun! and S! from 3GIAP
 * 
 * Feel free to delete all the comments above and including this line from this file. ****/

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

public class 
Mission AMission
{

    public 
override void OnActorCreated(int missionNumberstring shortNameAiActor actor)
    {
        
base.OnActorCreated(missionNumbershortNameactor);

        if (
actor is AiAircraft)
        {
            switch ((
actor as AiAircraft).InternalTypeName())
            {

                case 
"bob:Aircraft.He-111P-2":

                    
Timeout(60, () =>    // Time in Seconds
                         
{
                             (
actor as AiAircraft).Destroy();
                         });
                    break;
            }
        }
    }


 
public 
override void OnTickGame()
{

// loads the 1st sub-mission in 10 min and repeates it every 60 min.
    
if (Time.tickCounter() % 20000 == 320// 108000 = 60 min repeat. 1800 = 10 min delay. 
        // pls. note!!! the 1st figure above must be always larger than 2nd!
  
{
      
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission1.mis");

      
// prints message on screen after mission load
      
GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");

      
// prints message on screen in 10 minutes
      
double initTime 0.0;
      
Timeout(initTime += 600, () =>
      {
          
GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
      });

      
// prints message on screen in 5 minutes
      
Timeout(initTime += 300, () =>
      {
          
GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
      });

   }

// loads the 2nd sub-mission, etc. the same way
       
if (Time.tickCounter() % 10800 == 1000//  108000 = 60 min repeat, 54000 = 30 min delay. 
    
{
        
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission2.mis");
        
GamePlay.gpHUDLogCenter("Mission2.mis loaded!"); 
      
double initTime 0.0;
      
Timeout(initTime += 600, () =>
       {
           
GamePlay.gpHUDLogCenter("Mission2 10 min message!");
       });
            
      
Timeout(initTime += 300, () =>
         {
             
GamePlay.gpHUDLogCenter("Mission2 15 min message!");
         });
    }

// loads the 3rd sub-mission
       
if (Time.tickCounter() % 10800 == 1500// 60 min repeat, 50 min delay 
       
{
           
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission3.mis");
           
GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

           
double initTime 0.0;
           
Timeout(initTime += 600, () =>
           {
               
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
           });
           
Timeout(initTime += 300, () =>
           {
               
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
           });
       }

// loads the 4th sub-mission
       
if (Time.tickCounter() % 10800 == 2000// 60 min repeat, 50 min delay 
       
{
           
GamePlay.gpPostMissionLoad("missions/Single/apocalypseLondon/mission4.mis");
           
GamePlay.gpHUDLogCenter("Mission4.mis loaded!");

           
double initTime 0.0;
           
Timeout(initTime += 600, () =>
           {
               
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
           });
           
Timeout(initTime += 300, () =>
           {
               
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
           });
       }


}



__________________

Last edited by David198502; 10-17-2011 at 02:03 PM.
Reply With Quote
  #6  
Old 10-17-2011, 04:14 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Quote:
Originally Posted by David198502 View Post
ok Kodiak...i tried the script.
the He's of the main mission disappear after the 60seconds, but all other He's of the submissions will stay on the map...

so i pasted the relevant part of the script in all the submissios to destroy these He's as well.....this works!

...but is it possible to edit the script of the main mission, that all He's, including the ones of the submissions, disappear?
Yes it's possible, you must set the MissionNumberListener = -1, -1 means the script 'listen' to all events in all missions. If you only want one mission are listen you must specify the MissionNumber of the mission.
The best place for the MissionNumberListener is a method that called at the begin of a Mission. Normaly i use OnBattleStarted()
Code:
    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        MissionNumberListener = -1;
    }
Quote:
i also saw that it is possible to load submissions randomly...but in your tutorial you have some conditions which determine whether a mission is loaded or not(mission x will not be loaded if one destroys friendly vehicle)...i would like to load submissions randomly, regardless of any conditions, every xx seconds.is that possible?

i think its a better solution for my purpose to load submissions by random than loading mission after mission in determined sequence, because this would add an surprising factor, and i think it would shorten the script drastically, if i want to have 20 or more submissions.
Yes its possible the only thing you need is in OnTickGame()
Code:
Random ZufaelligeMission = new Random();
       
            switch (ZufaelligeMission.Next(1,5))
            {
                case 1:
                    GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub1.mis");
                break;
                case 2:
                    GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub2.mis");
                break;
                case 3:
                    GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub3.mis");
                break;
                case 4:
                    GamePlay.gpPostMissionLoad("missions\\Single\\Samples\\TestSubmissions\\MissionNachladen6Sub4.mis");
                break;
                
            }
Reply With Quote
  #7  
Old 10-17-2011, 05:30 PM
David198502's Avatar
David198502 David198502 is offline
Approved Member
 
Join Date: Dec 2009
Location: Austria
Posts: 1,536
Default

ok tried it, but i still dont know when and how i use those parts....
this is what i have so far....

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

public class 
Mission AMission
{

 public 
override void OnBattleStarted()
    {
        
base.OnBattleStarted();

        
MissionNumberListener = -1;
    }

    public 
override void OnActorCreated(int missionNumberstring shortNameAiActor actor)
    {
        
base.OnActorCreated(missionNumbershortNameactor);

        if (
actor is AiAircraft)
        {
            switch ((
actor as AiAircraft).InternalTypeName())
            {

                case 
"bob:Aircraft.He-111P-2":

                    
Timeout(420, () =>    // Time in Seconds
                         
{
                             (
actor as AiAircraft).Destroy();
                         });
                    break;
            }
        }
    }


 
public 
override void OnTickGame()
{
Random ZufaelligeMission = new Random();
       
            switch (
ZufaelligeMission.Next(1,5))
            {
                case 
1:
                    
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\mission1.mis");
                break;
                case 
2:
                    
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission2.mis");
                break;
                case 
3:
                    
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission3.mis");
                break;
                case 
4:
                    
GamePlay.gpPostMissionLoad("missions\\Single\\apocalypseLondon\\mission4.mis");
                break;
                
            }

}
}
}

there is a main mission, with a bf109 and 9He's(which should be destroyed after xx seconds)

after xx seconds i want the game to load one mission ,selected randomly out of 4 submissions.
i also want the He's loaded with the submission to be destroyed after the xx seconds, like the ones from the main mission.
and i want the game to repeat that process, so that every xx seconds a new mission is loaded randomly.....so that the mission can run forever
__________________

Last edited by David198502; 10-17-2011 at 05:33 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

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:55 PM.


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