Results 1 to 30 of 33

Thread: Campaign progress script

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Campaign progress script

    One of (many) complains of SP players is the lack of visible progress through campaigns.

    For "oficial" and third part campaigns at end of mission is show the default "Statistics" with player air kills (only) and squadron loses, and after a pre-made debriefing screen for success or failure, with the button for fly next mission or restart...

    Statistics.jpg

    Desastersoft campaigns improve this a bit, though use of custom DLL, showing more details of the mission, over a custom created interface:

    http://yoyosims.pl/sites/default/fil...tersoft_15.jpg

    REDUX campaign's use an script in a way I don't like, time from time a "score board" is show on screen... like in a football match.

    The "Geniok" template from 09/2011 used in "Cliffs of Dover" campaign and other 3rd part has a "parser" for supposed track player kills and show this in next mission briefing, but I an not able to make this work, probable some changes in patches affect that old code.

    Digging in "oldSukhoi leftovers of war" I find an old (06/2011) Russian made campaign that include a script that partially "band-aid" this lack.

    The script track:

    Enemy losses
    Side looses
    Squadron looses
    Player victories


    Through:

    Code:
       int r  =  0;
    	bool cmpl = false;
    	int cEnemy = 0;
        int cFriendly = 0;
        int cPlayer = 0;
        int MySquad = 0;
       	string b, tx1;
    	string[] br = new string[100]; 
    	int cEnemyS, 	cFriendlyS, cPlayerS, MySquadS;
    - Question; is possible add track for ground kills, for use in bombers campaigns?

    So at end of mission, after "Statistics" page you have:

    Mission results.jpg

    But... an "It's CloD!" (script author point this issue*), notice at top/left of the screen: "Battle Failure", no mater if you/your side won the battle this is showed.

    *
    The result of the last mission will be displayed in the post-flight briefing; do not pay attention to the inscription on the top left "Battle Failure".
    Above text is my interpretation of Google translation from Russian (editable part).

    I notice this script has no reference for "Campaign.dll" at top, but have for "//-$debug"
    so I add, with the path in the format of 5.00x (third part campaigns in Documents\1C... \custom folder):
    //$reference parts/core/Campaign.dll (thanks Varrattu for show the new path).

    But this don't change the "Battle Failure" screen...

    The script - UPDATE - Fixed the Battle Failure/Success screen

    Spoiler: 

    Code:
    //$reference parts/core/Campaign.dll
    //-$debug
    using System;
    using System.IO;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    
    public class Mission : maddox.game.campaign.Mission
    {
    
        int r  =  0;
    	bool cmpl = false;
    	int cEnemy = 0;
        int cFriendly = 0;
        int cPlayer = 0;
        int MySquad = 0;
       	string b, tx1;
    	string[] br = new string[100]; 
    	int cEnemyS, 	cFriendlyS, cPlayerS, MySquadS;	    
    
     public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList) 
        {              
            if (actor is AiAircraft) 
            {
                if (!(actor is AiAircraft))
    			return; 
    		
    		if (shortName.IndexOf("92Sqn",0) > 0)  MySquad++;
    		
                if (actor.Army() == 2) cEnemy++;
                if (actor.Army() == 1) cFriendly++;
                if (actor.Army() == 2) {
                    if (GamePlay.gpPlayer().Place() != null) {
                        bool playerWin = false;
                        foreach (DamagerScore i in initiatorList) {
                            if (i.initiator != null && i.initiator.Actor == GamePlay.gpPlayer().Place()) {
                                playerWin = true;
                            }
                        }
                        if (playerWin) cPlayer++;
                    }
                }
               SaveRezult (cmpl); 
            }
        }
    
    private void SaveRezult (bool CComplite) 
    {
    int n1 = 1;
    	int j = 0;
    StreamReader f2 = new StreamReader(@"C:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\mission\campaign\custom\campaign_Spitfires_over_Dunkik\m1.txt");
    b =  f2.ReadLine();
    cEnemyS = Int32.Parse(b) + cEnemy;
    b =  f2.ReadLine();
    cFriendlyS = Int32.Parse(b) + cFriendly;
    b =  f2.ReadLine();
    MySquadS = Int32.Parse(b) + MySquad;
    b =  f2.ReadLine();
    cPlayerS = Int32.Parse(b) + cPlayer;
    f2.Close();
    
    StreamWriter f3 = new StreamWriter(@"C:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\mission\campaign\custom\campaign_Spitfires_over_Dunkik\m2.txt");
    f3.WriteLine(String.Format("{0}", cEnemyS));
    f3.WriteLine(String.Format("{0}", cFriendlyS));
    f3.WriteLine(String.Format("{0}", MySquadS));
    f3.WriteLine(String.Format("{0}", cPlayerS));
    f3.Close();
    	
    StreamReader f1 = new StreamReader(@"C:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\mission\campaign\custom\campaign_Spitfires_over_Dunkik\m2.briefing");
    do 
    {
    b =  f1.ReadLine();
    br[n1++] = b;
    }				
     while (b  != "[2]") ;
    
    					f1.Close();		
    
    					StreamWriter f = new StreamWriter(@"C:\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\mission\campaign\custom\campaign_Spitfires_over_Dunkik\m2.briefing");
    					while (++j<n1)	 f.WriteLine(br[j]);
    					if (CComplite)
    					f.WriteLine("<Name>");
    					f.WriteLine("Success");
    					f.WriteLine("<Description>");
    					if (CComplite) f.WriteLine("Mission accomplished!");
    					else f.WriteLine("Mission tasks incomplete!");
    					if (MySquad >0) f.WriteLine("MISSION RESULTS");
    					else f.WriteLine("Overall, the squad performed well on the last mission.");
    
    					f.WriteLine(String.Format("RAF claims  -  {0} ", cEnemy));
    					f.WriteLine(String.Format("RAF losses  -  {0} ", cFriendly));
    					f.WriteLine(String.Format("Squadron claims  -  {0} ", MySquad));
    					f.WriteLine(String.Format("Personal claims  -  {0} ", cPlayer));
    
    					j = (cEnemy - cFriendly);
    				
    					if (j<0) f.WriteLine("The overall outcome of the mission was unsatisfactory. The RAF suffer heavy losses.");
    					if (j==0)
    						{
    						 if (cEnemy > 0) f.WriteLine("RAF's losses in the last battle were moderate. However, the overall performance needs to improve, the Luftwaffe has more aircraft.");
    						else 	 f.WriteLine("The squadron's performance needs to improve.");
    						}
    					if (j > 0)   f.WriteLine("The RAF it has performed well, the enemy's losses have been heavy.");
    
    					f.WriteLine(tx1);
    						
    					f.WriteLine("  ");
    					f.WriteLine("CAMPAIGN PROGRESS");
    					f.WriteLine(String.Format("RAF claims  -  {0} ", cEnemyS));
    					f.WriteLine(String.Format("RAF losses  -  {0} ", cFriendlyS));
    					f.WriteLine(String.Format("Squadron losses  -  {0} ", MySquadS));
    					f.WriteLine(String.Format("Personal claims  -  {0} ", cPlayerS));
    
    
    					f.WriteLine("[3]");
    					f.WriteLine("<Name>");
    					f.WriteLine("Failure");
    					f.WriteLine("<Description>");
    					if (CComplite) f.WriteLine("Mission accomplished!");
    					else f.WriteLine("Mission tasks incomplete!");
    							if (MySquad >0) f.WriteLine("Results of the last mission:");
    							else f.WriteLine("The squadron's performance needs to improve.");
    
    					f.WriteLine(String.Format("RAF claims  -  {0}, ", cEnemy));
    					f.WriteLine(String.Format("RAF losses  -  {0}, ", cFriendly));
    					f.WriteLine(String.Format("Squadron losses  -  {0}, ", MySquad));
    					f.WriteLine(String.Format("Personal claims  -  {0}, ", cPlayer));
    					
    					j = (cEnemy - cFriendly);
    				
    					if (j<0) f.WriteLine("The RAF's performance in the battle has been unsatisfactory, attrition favors the Luftwaffe.");
    					if (j==0)
    						{
    						 if (cEnemy > 0) f.WriteLine("RAF's losses in the last battle were moderate. However, the overall performance needs to improve, the Luftwaffe has more aircraft.");
    						else 	 f.WriteLine("The squadron's performance was unsatisfactory.");
    						}
    					if (j > 0)   f.WriteLine("The RAF has performed well, causing significant losses to the enemy.");
    
    					f.WriteLine(tx1);
    					if (MySquad>0)
    					f.WriteLine("The squadron's performance was remarkable.");  
    					else 
    					f.WriteLine("The squadron's performance increased. Very well, gentlemen.");  
    
    					f.WriteLine(" ");	
    					f.WriteLine("CAMPAIGN PROGRESS");
    					f.WriteLine(String.Format("RAF claims  -  {0} ", cEnemyS));
    					f.WriteLine(String.Format("RAF losses  -  {0} ", cFriendlyS));
    					f.WriteLine(String.Format("Squadron losses  -  {0} ", MySquadS));
    					f.WriteLine(String.Format("Personal claims  -  {0} ", cPlayerS));
    					f.WriteLine("<Slide>");
    					if (CComplite) 
    					f.WriteLine("CampaignSuccess2.jpg");
    					else f.WriteLine("CampaignFailure2.jpg");
    					f.WriteLine("<Caption>");
    					f.Close();
    
    }
    
    // --------------------------
    
    public override void OnBattleStarted() 
    {			
    
    					base.OnBattleStarted() ;
    					MissionNumberListener = -1;
    					tx1 = "The mission's tasks were not all completed. Replay is recommended.";
    					SaveRezult (false) ;
        }
    
        public override void OnTrigger(int missionNumber, string shortName, bool active) {
    		
            if ("trigger_3".Equals(shortName) && active) 
    		{
               	if (++r  == 4) 
    			{
    			GamePlay.gpHUDLogCenter("Waypoint reached.");
    			tx1 = "Task have been completed.";
    			
    cmpl = true;
    			SaveRezult (true) ;
    			}
    			else GamePlay.gpHUDLogCenter(String.Format("#  {0}", r));
    
                GamePlay.gpGetTrigger(shortName).Enable = false;
            }
    
    
    if ("trigger_1".Equals(shortName) && active) 
    		{
               
    				
                GamePlay.gpGetTrigger(shortName).Enable = false;
    			if (++r  == 4) 
    {
    			GamePlay.gpHUDLogCenter("Waypoint reached.");
    			tx1 = "Task have been completed.";
    cmpl = true;
    			SaveRezult (true) ;
    			}
    			else GamePlay.gpHUDLogCenter(String.Format("#  {0}", r));
    
    			AiAction action1 = GamePlay.gpGetAction("action_1");
                if (action1 != null)
    			{
                        action1.Do();					
    			}
    		  }
    
    if ("trigger_2".Equals(shortName) && active) 
    		{
               
    			GamePlay.gpGetTrigger(shortName).Enable = false;
    			if (++r == 4) 
    {
    			GamePlay.gpHUDLogCenter("Waypoint reached.");
    			tx1 = "Task have been completed.";
    cmpl = true;
    			SaveRezult (true) ;
    			}			
    			else GamePlay.gpHUDLogCenter(String.Format("#  {0}", r));
    		}
    
    if ("trigger_6".Equals(shortName) && active) 
    		{          
    			GamePlay.gpGetTrigger(shortName).Enable = false;
    			if (++r == 4) 
    {
    			GamePlay.gpHUDLogCenter("Waypoint reached.");
    			tx1 = "Task have been completed.";
    			cmpl = true;
    			SaveRezult (true) ;
    			}			
    			else GamePlay.gpHUDLogCenter(String.Format("#  {0}", r));
    		}
    
    		if ("trigger_7".Equals(shortName) && active) 
    		{
               
    			GamePlay.gpGetTrigger(shortName).Enable = false;
    			if (r < 4)
    			{ 
    			GamePlay.gpHUDLogCenter("Waypoint reached.");
    			tx1 = "Task have been completed.";
    			cmpl = true;
    			SaveRezult (true) ;
    			}
    		}
        }
    	
    	int countEnemyDead = 0;
        int countFriendDead = 0;	           
        private void checkLanded(AiAircraft aircraft) 
    	{		
            if (GamePlay.gpPlayer().Place() != aircraft)
                return;
    
            bool complete = ((countEnemyDead - countFriendDead) >= 0);
    
            if (Campaign != null) 
    		{
                if (Campaign.battleSuccess != null)
                    return;
                Campaign.battleSuccess = complete;
            }
            if (complete) 
    		{
                GamePlay.gpHUDLogCenter("MISSION COMPLETE");
            }
            Timeout(20.0, () => 
    		{
                GamePlay.gpHUDLogCenter("Press Esc to end mission.");
            });
        }
    
        public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) 
    	{
            checkLanded(aircraft);
        }
        public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) 
    	{
            checkLanded(aircraft);
        }
    }


    Besides the script is used 3 text files.

    ccc.txt EDIT - Can use m0.txt if want
    m#.txt (# number of mission in campaign, so each mission have his own)
    m#.briefing (# number of mission in campaign, so each mission have his own)

    ccc and m#.txt have this for mission 1
    Code:
    0
    0
    0
    0
    This files are updated by script and used to update the "m#.briefing"

    Briefing contains (text is my interpretation of Google translation from Russian):

    [1] Is show at start of mission

    [2] Is show at end of mission, in the "Mission Failure" (why?) screen

    Spoiler: 

    Code:
    [1]
    <Name>
    Intro
    <Description>
    May, 23rd. Early morning.
    Yesterday our squadron was transferred from the main airfield Hornchurch to Ramsgate, closer to the main events in which we will soon become participants. And events are clearly not unfolding in our favor. In Europe, the British expeditionary forces were recently cut off from the main forces of the Allies in France, and the continued rapid offensive of the Germans could lead to their complete surrender. Of course, unless a miracle happens.
    
    Beautiful sunrise. The morning spring sun distracts from gloomy thoughts about the war, thoughts go into pleasant memories of girls, pubs and other joys of a young gentleman.
    
    But the pre-flight briefing instantly reminds us of the reality. Our squadron starts fighting. 
    
    Objective: fly to the area south of Dunkirk, patrol over the coastal strip from Dunkirk harbor to the front line south of Dunkirk itself. 
    If you spot an enemy aircraft, shoot him down. 
    Considering that you will be patrolling over the front line, there is a high probability of encountering German bombers, whose activity in this area has been very high in recent days.
    
    <Slide>
    m1.jpg
    
    <Caption>
    
    PLAYER: Mission start in the air on the way to the first patrol checkpoint. The patrol tasks will be considered completed when all checkpoints have been passed and several German aircraft have been shot down, or after 15 minutes of patrolling.
    
    [2]
    <Name>
    Success
    <Description>
    Mission accomplished!
    Results of the last mission:
    RAF claims  -  13 
    RAF losses  -  10 
    Squadron losses  -  8 
    Personal claims  -  2 
    The RAF it has performed well, the enemy's losses have been heavy.
    All tasks of the mission have been completed.
      
    Campaign progress:
    RAF claims  -  13 
    RAF losses  -  10 
    Squadron losses  -  8 
    Personal claims  -  2 
    [3]
    <Name>
    Failure
    <Description>
    Mission accomplished!
    Results of the last mission:
    RAF claims  -  13 
    RAF losses  -  10 
    Squadron losses -  8 
    Personal claims  -  2 
    The RAF has performed well, causing losses to the enemy in greater numbers than its own.
    All tasks of the mission have been completed.
     
    Campaign progress:
    RAF claims  -  13 
    RAF losses  -  10 
    Squadron losses -  8 
    Personal claims -  2 
    <Slide>
    CampaignSuccess1.jpg
    <Caption>


    Update after play the second mission of campaign, all work as expected, but are a line in Cyrilics that I don't figure where is, and this pre made comments need be very neutral, because in the last mission Squad lost 2 planes, but the text say that have no losses.

    Statistics-3.jpg

    The script has a second part - that I remove; what check, through "passThru" triggers if player reach each mission checkpoint (waypoint) and show that... "football score board".

    But this part of script can be used for more useful things, for example, tell player the HDG for next waypoint. Latter I post this part (forum message has 20.000 characters limit).
    Last edited by 1lokos; Oct-04-2020 at 20:18.

  2. Likes Marcost, von Graf liked this post

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
  •