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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 02-08-2012, 05:40 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

This is part of my Debriefing Script (work in progress)
I store the playernames of the players which use a plane with timestamps and position for entering and leaving. So i can decide to evaluate the usage of an actor. If a player leaves the plane short before it is Killed, i can get the players using this plane anyway .

Code:
        public class ActorUsage
        {

            public class CrewMember
            {
                public string CrewmanName { get; set; }
                public int CrewmanPlace { get; set; }
                internal DateTime EnterTime { get; set; }
                internal DateTime LeaveTime { get; set; }
                internal Point3d EnterPlanePos { get; set; }
                internal Point3d LeavePlanePos { get; set; }


                public CrewMember(Player player, int placeIndex, Point3d enterPos)
                {
                    this.CrewmanName = player.Name();
                    this.CrewmanPlace = placeIndex;
                    this.EnterPlanePos = enterPos;
                    this.EnterTime = DateTime.Now;
                }
            }


            public class ActorDetails
            {
                public AiActor actor { get; set; }
                public AiAirport StartAirport { get; set; }
                public bool AircraftUsed = false;
                public bool AircraftDamaged = false;
                public List<CrewMember> CrewHistory = new List<CrewMember>();


                public bool IsActorAirborne(AiActor actor)
                {

                    if (actor == null
                       || !actor.IsAlive()
                       || !(actor as AiAircraft).IsAirborne()
                       || (actor as AiAircraft).getParameter(part.ParameterTypes.Z_AltitudeAGL, -1) <= 2.0
                       || (actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0
                       )
                    {
                        return false;
                    }
                    else
                        return true;
                }
            }


            public List<ActorDetails> ActorHistory = new List<ActorDetails>();


            public void PlaceEnter(Player player, AiActor actor, int placeIndex)
            {
                if (actor != null && !ActorHistory.Exists(item => item.actor == actor))
                {
                    ActorDetails NewActor = new ActorDetails();
                    NewActor.actor = actor;
                    NewActor.CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos()));
                    ActorHistory.Add(NewActor);
                }
                else if (actor != null)
                {
                    int i = ActorHistory.FindIndex(item => item.actor == actor);

                    if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name())))
                    {
                        int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name()));
                        ActorHistory[i].CrewHistory[j].CrewmanPlace = placeIndex;
                    }
                    else
                    {
                        ActorHistory[i].CrewHistory.Add(new CrewMember(player, placeIndex, (actor as AiAircraft).Pos()));
                    }

                }
            }


            public void PlaceLeave(Player player, AiActor actor, int placeIndex)
            {
                if (actor != null && ActorHistory.Exists(item => item.actor == actor))
                {

                    int i = ActorHistory.FindIndex(item => item.actor == actor);

                    if (ActorHistory[i].CrewHistory.Exists(item => item.CrewmanName.Equals(player.Name())))
                    {
                        int j = ActorHistory[i].CrewHistory.FindIndex(item => item.CrewmanName.Equals(player.Name()));
                        Point3d tmpPoint = ActorHistory[i].CrewHistory[j].EnterPlanePos;

                        if ((actor as AiAircraft).Pos().distance(ref tmpPoint) < 1)
                        {
                            ActorHistory[i].CrewHistory.RemoveAt(j); // no position changes of plane so delete the crewman entry
                        }
                        else
                        {
                            ActorHistory[i].CrewHistory[j].LeavePlanePos = (actor as AiAircraft).Pos();
                            ActorHistory[i].CrewHistory[j].LeaveTime = DateTime.Now;
                            ActorHistory[i].AircraftUsed = true;
                        }
                    }
                }
            }


            public List<KeyValuePair<string, int>> ActorDead(AiActor actor)
            {
                List<KeyValuePair<string, int>> tmpActorPlace = new List<KeyValuePair<string, int>>();

                if (ActorHistory.Exists(item => item.actor == actor))
                {
                    int i = ActorHistory.FindIndex(item => item.actor == actor);

                    ActorHistory[i].CrewHistory.ForEach(item =>
                        {
                            tmpActorPlace.Add(new KeyValuePair<string, int>(item.CrewmanName, item.CrewmanPlace));
                        });

                    return tmpActorPlace;
                }
                else return null;
            }



            public List<AiActor> GetActors()
            {
                List<AiActor> tmpActors = new List<AiActor>();

                foreach (ActorDetails ad in ActorHistory)
                {
                    tmpActors.Add(ad.actor);
                }

                return tmpActors;
            }


            public List<string> GetActorPlayer()
            {
                List<string> tmpStrings = new List<string>();

                foreach (ActorDetails ad in ActorHistory)
                {
                    foreach (CrewMember cm in ad.CrewHistory)
                    {
                        tmpStrings.Add(ad.actor.Name().ToString() + "::" + ad.AircraftUsed + "::" + cm.CrewmanName + "::" + cm.CrewmanPlace.ToString() + "::" + cm.EnterTime.ToShortTimeString() + "::" + cm.LeaveTime.ToShortTimeString());
                    }
                }

                return tmpStrings;
            }
        }
Reply With Quote
 


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 10:42 PM.


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