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 05-23-2012, 10:52 PM
von Pilsner von Pilsner is offline
Approved Member
 
Join Date: Apr 2011
Posts: 377
Smile Script Help - Read damaged objects into file

I suspect this has already been accomplished, but I can not find it through Google or Forum Search so I figure I will ask here...

I have a mission.cs script that I have been using, it starts with the usual:
Code:
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;

public class Mission : maddox.game.AMission
What I would like it to do is write (append actually) to a file named 'destroyed.ini' (in the same directory as my mission) as static objects get destroyed so during the course of a mission the file may fill up like:
Code:
[Static]
Stationary.Environment.JP3_Generator_15_KW_UK1 gb 178768.08 197313.52 105.00, 2
Artillery.3_inch_20_CWT_QF_Mk_I_StandAlone2 gb 136914.39 198372.09 -60.00, 2
Stationary.Ammo_Vehicles.3inch_QF_AA_composition3_UK1 nn 136921.30 198377.00 -90.00, 2
THe coordinates are important because they will be used later to determine if it is the exact same static object that was destroyed. The suffix ',2' is just a placeholder but I would like it to end up in the file as well.

I would then like to use a separate script (my overall campaign.cs) to parse the file and use the list to not create static objects in the next mission.

I used to do C programming (command line), but the object model of C# is taking me some time to wrap my head around. If someone could help me write the objects to a file I believe I have the skills to parse the file and use the data in my own (campaign) script.

The reason I would like it in a mission script is because it is for single player use.

Thanks,
von Pilsner

p.s. - I have read through the basic tutorials and script examples so if that is all you are able to suggest, I'm doing that right now...

Last edited by von Pilsner; 05-23-2012 at 10:59 PM.
Reply With Quote
  #2  
Old 05-23-2012, 11:09 PM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Destruction of actors (moving ships, vehicles, planes) can be tracked via the OnActorDestroyed method, but there's no method that exposes the destruction of statics objects.
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
Reply With Quote
  #3  
Old 05-23-2012, 11:22 PM
von Pilsner von Pilsner is offline
Approved Member
 
Join Date: Apr 2011
Posts: 377
Default

Quote:
Originally Posted by salmo View Post
Destruction of actors (moving ships, vehicles, planes) can be tracked via the OnActorDestroyed method, but there's no method that exposes the destruction of statics objects.
Thanks, that is what I was afraid of...
Reply With Quote
  #4  
Old 05-24-2012, 01:27 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default

It totally blows! Two little fixes. Track destruction of Static Objects and Track destruction of pre-loaded objects (houses) on Maps. Then we can have fun with carpet bombing and attacking London and other cities without placing a Blue or Red static object within it to mimic destruction.
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
Reply With Quote
  #5  
Old 05-24-2012, 01:55 AM
Smokeynz Smokeynz is offline
Approved Member
 
Join Date: Apr 2011
Posts: 106
Default

I have the following code in my current "work in progress" script
My intension was simple plane spawning limits and mission completion.

The limitation works but mission completion has issues.
However what I have found is relationships between various aspects.
Destroyed can be killed or removed by various means.
Killed is different to destroyed.

I created the following so I could see what is going on. Doesnt really help objects though.

Code:
/*=========================================*/

    #region Resource Counters

/*=========================================*/
    
    int ActorsCreated;
    int ActorsCreatedLast;
    int ActorsDestroyed;
    int ActorsDestroyedLast;
    int ActorsDead;
    int ActorsDeadLast;

    int AircraftLanded;
    int AircraftLandedLast;    
    int AircraftCrashed;
    int AircraftCrashedLast;
    int AircraftKilled;
    int AircraftKilledLast;

    int BlueActors;
    int BlueDOA;
    int BlueAircraftInService;
    int BlueAircraftLost;
    int BlueReserve;// = 300;//config list once setup

    int RedActors;
    int RedDOA;
    int RedAircraftInService;
    int RedAircraftLost;
    int RedReserve;// = 300;     
    
    int PlaneLimit; //total aircraft in game at any one time

    private void ActorResources(AiActor actor)
    {
        if (ActorsCreated > ActorsCreatedLast)
        {
            if (actor.Army() == 1)
            {
                RedActors++;
                RedAircraftInService++;
                RedReserve--;                   
            }
            if (actor.Army() == 2)
            {
                BlueActors++;
                BlueAircraftInService++;
                BlueReserve--;            
            }
            ActorsCreatedLast = ActorsCreated;
        }
        if (ActorsDestroyed > ActorsDestroyedLast)
        {
            if (actor.Army() == 1)
            {
                RedAircraftInService--;
                RedReserve++;
            }
            if (actor.Army() == 2)
            {
                BlueAircraftInService--;
                BlueReserve++;
            }
            ActorsDestroyedLast = ActorsDestroyed;
        }

        if (ActorsDead > ActorsDeadLast)
        {
            if (actor.Army() == 1)
            {
                RedAircraftInService--;
                RedDOA++;
            }
            if (actor.Army() == 2)
            {
                BlueAircraftInService--;
                BlueDOA++;
            }
            ActorsDeadLast = ActorsDead;
        }
        
        LimitPlanes();
    }

    private void AircraftResources(AiAircraft aircraft)
    {
        if (AircraftLanded > AircraftLandedLast)
        {
            if (aircraft.Army() == 1)
            {
                RedAircraftInService--;
                RedReserve++;
            }
            if (aircraft.Army() == 2)
            {
                BlueAircraftInService--;
                BlueReserve++;
            }
            AircraftLandedLast = AircraftLanded;
        }
        if (AircraftCrashed > AircraftCrashedLast)
        {
            if (aircraft.Army() == 1)
            {
                RedAircraftInService--;
                RedAircraftLost++;
                //RedReserve--;
            }
            if (aircraft.Army() == 2)
            {
                BlueAircraftInService--;
                BlueAircraftLost++;
                //BlueReserve--;
            }
            AircraftCrashedLast = AircraftCrashed;
        }

        if (AircraftKilled > AircraftKilledLast)
        {
            if (aircraft.Army() == 1)
            {
                RedAircraftInService--;
                RedAircraftLost++;
            }
            if (aircraft.Army() == 2)
            {
                BlueAircraftInService--;
                BlueAircraftLost++;
            }
            AircraftKilledLast = AircraftKilled;
        }        

        LimitPlanes();
    }

    private void LimitPlanes()
    {        
        if (RedAircraftInService > PlaneLimit)
        {
            rl = 1;
            gl = 3;
            GamePlay.gpLogServer(null, "Red Ingame limit reached: PlaneLimit:{0} InService:{1}", new object[] { PlaneLimit, RedAircraftInService });
        }
        else { rl = 0; gl = 0; }
        if (BlueAircraftInService > PlaneLimit)
        {
            bl = 2;
            gl = 3;
            GamePlay.gpLogServer(null, "Blue Ingame limit reached: PlaneLimit:{0} InService:{1}", new object[] { PlaneLimit, BlueAircraftInService });
        }
        else { bl = 0; gl = 0;}
    }   

    public override void OnActorDestroyed(int missionNumber, string shortName, AiActor actor)
    {
        base.OnActorDestroyed(missionNumber, shortName, actor);
        if (actor != null)
        {
            if (actor is AiAircraft)
            {                
                ActorsDestroyed++;
                ActorResources(actor);
            }
        }
    }

    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, System.Collections.Generic.List<DamagerScore> damages)
    {
        base.OnActorDead(missionNumber, shortName, actor, damages);
        if (actor != null)
        {
            if (actor is AiAircraft)
            {                
                ActorsDead++;
                ActorResources(actor);
            }
        }
    }

    public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftLanded(missionNumber, shortName, aircraft);
        if (aircraft != null)
        {            
            AircraftLanded++;
            AircraftResources(aircraft);
        }
    }

    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        if (aircraft != null)
        {            
            AircraftCrashed++;
            AircraftResources(aircraft);
        }
    }

    public override void OnAircraftKilled(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftKilled(missionNumber, shortName, aircraft);
        if (aircraft != null)
        {            
            AircraftKilled++;
            AircraftResources(aircraft);
        }   
    } 

    /*=========================================*/

    #endregion

    /*=========================================*/

This goes in ticktimer section to report the results

Code:
// Mission config collection cycle
        if (Time.tickCounter() % 1800 == 900)
        {
            GamePlay.gpLogServer(null, "-------------------------------------------------", null);
            GamePlay.gpLogServer(null, "           [Overall Resources Count]", null);
            GamePlay.gpLogServer(null, "  Actors:: Created:{0} Destroyed:{1}   Dead:{2}", new object[] { ActorsCreated, ActorsDestroyed, ActorsDead });
            GamePlay.gpLogServer(null, "Aircraft::  Landed:{0}   Crashed:{1} Killed:{2}", new object[] { AircraftLanded, AircraftCrashed, AircraftKilled });
            GamePlay.gpLogServer(null, "-------------------------------------------------", new object[] { });
            GamePlay.gpLogServer(null, "                [Blue Resources]", null);
            GamePlay.gpLogServer(null, "  Pilots::    Actors:{0}  DOA:{1}", new object[] { BlueActors, BlueDOA });
            GamePlay.gpLogServer(null, "Aircraft:: InService:{0} Lost:{1} Reserve:{2}", new object[] { BlueAircraftInService, BlueAircraftLost, BlueReserve });
            GamePlay.gpLogServer(null, "-------------------------------------------------", null);
            GamePlay.gpLogServer(null, "                [Red  Resources]", null);
            GamePlay.gpLogServer(null, "  Pilots::    Actors:{0}  DOA:{1}", new object[] { RedActors, RedDOA });
            GamePlay.gpLogServer(null, "Aircraft:: InService:{0} Lost:{1} Reserve:{2}", new object[] { RedAircraftInService, RedAircraftLost, RedReserve });
            GamePlay.gpLogServer(null, " ------------------------------------------------", null);
        }
Reply With Quote
  #6  
Old 05-24-2012, 04:34 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

@pilsner
You can "register" the destroying of a static object (not all, no house for example) only with TGroundDestroyed Trigger. So you must add a TGroundDestroyed to every static you wana check, at the moment.
Reply With Quote
  #7  
Old 05-25-2012, 02:14 AM
von Pilsner von Pilsner is offline
Approved Member
 
Join Date: Apr 2011
Posts: 377
Default

Very helpful, Thanks!
Reply With Quote
Reply


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 11:41 PM.


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