Results 1 to 7 of 7

Thread: OnBombExplosion

  1. #1
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    OnBombExplosion

    Trying to get craters to work with this code but I am coming up with System.Math Error.

    Code:
     		
        public override void OnBombExplosion(string title, double mass, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
        {
    /* 		string cratertype = "BombCrater_firmSoil_mediumkg";
            if (mass > 100) cratertype = "BombCrater_firmSoil_largekg"; //250lb bomb or larger
            if (mass > 200) cratertype = "BombCrater_firmSoil_EXlargekg"; //500lb bomb or larger.  EXLarge is actually 3 large craters slightly
    {8/
    Any help just trying to put a crater when a bomb hits the ground. All ground except water....

  2. #2
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: OnBombExplosion

    Quote Originally Posted by BlacKnight View Post
    Trying to get craters to work with this code but I am coming up with System.Math Error.

    Code:
     		
        public override void OnBombExplosion(string title, double mass, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
        {
    /* 		string cratertype = "BombCrater_firmSoil_mediumkg";
            if (mass > 100) cratertype = "BombCrater_firmSoil_largekg"; //250lb bomb or larger
            if (mass > 200) cratertype = "BombCrater_firmSoil_EXlargekg"; //500lb bomb or larger.  EXLarge is actually 3 large craters slightly
    {8/
    Any help just trying to put a crater when a bomb hits the ground. All ground except water....
    Bombs create craters without any need for code.

  3. #3
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: OnBombExplosion

    I have not seen them create craters... Is that in the update because my ai after I drop I have check airfield and nothing...

  4. #4
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: OnBombExplosion

    Quote Originally Posted by BlacKnight View Post
    I have not seen them create craters... Is that in the update because my ai after I drop I have check airfield and nothing...
    Yes I think they do. Attached was taken from testing my hardest day missions. Think that was caused by Stukas with the large and two small loadout.

    craters.jpg
    I am Yo-Yo not YoYo (that's someone else)

  5. Likes ATAG_Snapper liked this post
  6. #5
    Combat pilot
    Join Date
    Aug 2020
    Posts
    181
    Post Thanks / Like
    Total Downloaded
    121.31 MB

    Re: OnBombExplosion

    That is OFFLINE, Online is a different story...

  7. #6
    Student Pilot
    Join Date
    Apr 2023
    Posts
    13
    Post Thanks / Like
    Total Downloaded
    0

    Re: OnBombExplosion

    Quote Originally Posted by ATAG_Oskar View Post
    Bombs create craters without any need for code.
    There are reasons why you might want to create a crater programatically though, I know we did for SoW although with the architecture we used it worked a little differently to the OP's requirement.

    Our code is here, we use mass much the same as you do so can't see why there's a math problem. What is the precise error thrown?

    We only record craters on airfields, and put them into the database for addition to the mission file which is compiled dynamically on run by our server "template manager" software.

    Code:
            
    public void AtBombExplosion(string title, double mass, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
            {
                Debug.DebugOutput("BombExplosion", 3);
                int objectiveid = ObjectiveHandling.CheckAreaTargetBombExplosion(mass, pos);
                if (objectiveid != 0)
                {
                    Objective obj = ObjectiveHandling.ReturnObjectiveFromID(objectiveid);
                    obj.SetBombWeightTaken(mass);
                    ObjectiveHandling.CheckForNewObjectiveRequired(obj.ID);
                    if (obj.Type == "Airfield" && mass>50)
                    {
                        stats.AddCraterToTable(objectiveid, pos);
                    }
                    Sortie s = PilotsHandling.FindSortie(initiator.Actor.Name());
                    if (s != null)
                    {
                        string _event = "Dropped Bomb on Objective";
                        string EventLabel1 = obj.Name;
                        string EventLabel2 = mass.ToString();
                        string EventLabel3 = " ";
                        string EventLabel4 = Battle.THIS.GamePlay.gpSectorName(obj.Location.x, obj.Location.y);
    
                        stats.AddEventToTable(_event, s.SortieID, EventLabel1, EventLabel2, EventLabel3, EventLabel4);
                    }
                }
            }
    once the crater is in the table, the mission file creates a row but used the object
    Code:
    buildings.House$BombCrater_100_kg

  8. #7
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: OnBombExplosion

    Also just noticed that SP craters created by bombs are set to disappear after one hour.

  9. Likes BlacKnight 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
  •