Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   Place and then Remove Static Objects after destruction. (http://forum.fulqrumpublishing.com/showthread.php?t=33421)

hc_wolf 07-23-2012 11:25 PM

Place and then Remove Static Objects after destruction.
 
Hello,

Two questions and I think I know the answer, just want to re-check.

1) If you destroy an object on the English map (Permanent Radar) or a Static Radar object placed in the .mis file, Do they come back after x minutes or stay destroyed?

2) If I place a Static Radar and then Bomb it, Bits scatter around the bomb site and it stays destroyed.. ..Is there a script that will remove the debris (Destroy AiGroundActorType.Radar)

I want to Destroy the Radar and then have it Re-spawn a little later. I have the script all working except for clearing the Destroyed Radar. So at the moment the new Radar spawns on the destroyed one.

from .mis file
Static4 Stationary.Radar.EnglishRadar1 gb 70506.68 171685.75 93.00

The below does not seem to work if I put this in mission script

Code:

    /*------------------Remove AIGround method---------------*/
    private void destroyGroundActor(AiGroundActorType type, int army)
    {
        if (GamePlay.gpGroundGroups(army) != null)
        {
            foreach (AiGroundGroup gg in GamePlay.gpGroundGroups(army))
            {
                if (gg != null && gg.GetItems().GetLength(0) > 0)
                {
                    foreach (AiActor ggActor in gg.GetItems())
                    {
                        if (ggActor != null)
                            if ((ggActor as AiGroundActor) != null && (ggActor as AiGroundActor).Type() == type)
                                (ggActor as AiGroundActor).Destroy();
                    }
                }
            }
        }
    }


Smokeynz 07-24-2012 04:23 AM

I seem to remember the CS of "CTF_cross_roundel by naryv" has items being cleared after destroyed.

Also only current beta has code for objects as being specific ground items, I cant run the beta without crashing so can't test it.

FG28_Kodiak 07-24-2012 04:50 AM

1) they stay destroyed

2) Radars are no GroundActors they are static objects so you must use the new OnStationaryKilled (works since the latest beta patch)
Code:

public override void OnStationaryKilled(GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
{
    base.OnStationaryKilled(_stationary, initiator, eventArgInt);

    _stationary.Destroy();
}


hc_wolf 07-24-2012 05:38 AM

Quote:

Originally Posted by FG28_Kodiak (Post 447812)
1) they stay destroyed

2) Radars are no GroundActors they are static objects so you must use the new OnStationaryKilled (works since the latest beta patch)
Code:

    /*------------------Remove Static stationary Ground method---------------*/


    Dictionary<AiGroundActorType, int> PointsforGroundTargets = new Dictionary<AiGroundActorType, int>()
    {
        {AiGroundActorType.Radar, 12},
    };


    /*------------------Remove AIGround method---------------*/
    private void destroyGroundActor(AiGroundActorType type, int army)
    {
        if (GamePlay.gpGroundGroups(army) != null)
        {
            foreach (AiGroundGroup gg in GamePlay.gpGroundGroups(army))
            {
                if (gg != null && gg.GetItems().GetLength(0) > 0)
                {
                    foreach (AiActor ggActor in gg.GetItems())
                    {
                        if (ggActor != null)
                            if ((ggActor as AiGroundActor) != null && (ggActor as AiGroundActor).Type() == type)
                                (ggActor as AiGroundActor).Destroy();
                               
                    }
                }
            }
        }
    }

    /*------------------Remove Static stationary Ground method---------------*/
/*-----Below is to remove stationary objects listed in AiGroundActorType list----------*/

    public override void OnStationaryKilled(GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
    {
        base.OnStationaryKilled(_stationary, initiator, eventArgInt);

            if (GamePlay.gpGroundStationarys() != null)
        {
            foreach (GroundStationary gg in GamePlay.gpGroundStationarys())
            {
                if (gg != null && gg.GetItems().GetLength(0) > 0)
                {
                    foreach (AiActor ggActor in gg.GetItems())
                    {
                        if (ggActor != null)
                            if ((ggActor as OnstationaryKilled) != null && (ggActor as AiGroundActor).Type() == type)
                                (ggActor as _stationary.Destroy).Destroy();
                    }
                }
            }
        }
    }


thanks Kodiak. For the coed. I am having trouble making it work.
The end objective is that if the Radar is bombed and destroyed I want it to "despawn" The AiGroundActorType is "Radar", but in the _stationary there is no list for Radar.

(_stationary = AiGroundActorType.Radar);


Any clue on how I integrate the _Stationary Kill into the get rid of destroyed objects like the Radar?

hc_wolf 07-26-2012 05:32 AM

Kodiak or anyone? got any cluse on the above? Hels to clean up a mission after bombing runs are complete (less static objects on the map).

FG28_Kodiak 07-26-2012 07:24 AM

The stationary object don't use an enumerator (AiGroundActorType), they return strings,
you can get
Title = Name of the static;
Category = vehicle, aircraft etc. can be empty. Radars are empty.
Type = Radar etc.
i've not tested all possible values at the moment. Integrate this into the OnStationaryKilled to get the values by yourself.
Code:

GamePlay.gpLogServer(null, "OnStationaryKilled: Title: {0}; Category: {1}; Type: {2}", new object[]{_stationary.Title, _stationary.Category, _stationary.Type});
Example to remove all radars around 1000m from position a stationary was killed
Code:

    public override void OnStationaryKilled(GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
    {
        base.OnStationaryKilled(_stationary, initiator, eventArgInt);


        GamePlay.gpLogServer(null, "OnStationaryKilled: Title: {0}; Category: {1}; Type: {2}", new object[]{_stationary.Title, _stationary.Category, _stationary.Type});

        if (GamePlay.gpGroundStationarys() != null)
        {
            foreach (GroundStationary gg in GamePlay.gpGroundStationarys(_stationary.pos.x, _stationary.pos.y, 1000.0))
            {
                if(_stationary.Type.Equals("Radar"))
                    gg.Destroy();
            }
        }
 
    }


podvoxx 07-26-2012 07:32 AM

In the next patch will be extended capabilities of the method OnStationaryKilled.

FG28_Kodiak 07-26-2012 07:40 AM

Ok so it's more rough-and-ready at the moment :rolleyes:, hope they integrate the missionNumber so it would be easier to remove the objects. ;)

hc_wolf 07-26-2012 10:30 AM

Hi Kodiak,

Well thank you for the code. It works to a point. But the destroyed parts of the radar do not remove from the map. So the new radar just appears on top of the old.

May have to wait till patch and hope the destroyed parts remove after time maybe.

podvoxx 07-26-2012 04:12 PM

Quote:

Originally Posted by hc_wolf (Post 448301)

Well thank you for the code. It works to a point. But the destroyed parts of the radar do not remove from the map. So the new radar just appears on top of the old.

May have to wait till patch and hope the destroyed parts remove after time maybe.

Please describe your problem in detail whith mission code.
http://www.sukhoi.ru/forum/showthrea...=1#post1871936

FG28_Kodiak 07-26-2012 04:48 PM

@hc_wolf
BTW this should work for user placed stationary, not for stationaries that are already available on the map (Radars by Dover for example).

This has worked for me without problem:
Code:

    public override void OnStationaryKilled(GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
    {
        base.OnStationaryKilled(_stationary, initiator, eventArgInt);

        Timeout(10, () =>
                        {
                            _stationary.Destroy();
                        }
            );
    }


hc_wolf 07-26-2012 11:25 PM

Thanks Kodiak, will give this cut down version a try. If it still does not remove the damaged material I will post the mission and coding for Podvoxx on the supplied forum link.

Is podvoxx on the Dev team? I am been in direct comms with one of the others.

I have a few sample missions I can send them that exploit or show the code where particular odd events are occurring.

Including a Mesh error that repeats in server console with the Balloons.



Oh and just to be clear about the Radars destroyed parts not removing from Map. These are radars that are static objects imported in by a mission loading into another mission. I am not talking about destroying the pre-loaded radars on the map like Dover. These are radars placed on map from FMB and loaded into main mission from sub mission.

I wil post a mission on here http://www.sukhoi.ru/forum/showthrea...=68629&page=25

Now I know where the programmers are chatting on Sukhoi I will start posting my mission bug examples there for us all to discuss.

Ataros 07-27-2012 12:26 PM

naryv is a member of the dev team in that thread.

hc_wolf 08-05-2012 11:48 PM

Hi Kodiak,

Still not getting it to work.

I tried a couple of different methods, but The static Radar object when bombed keeps its broken bits laying around. So radar after Radar build on top od broken parts.

Below the idea is that the static object is placed in mission and then bombed.

It is destroyed and after a few seconds the destroyed parts should dissapear. Then 10 seconds later a new mission is called to spawn in a new Radar.

How can the below code and extra code be used to remove broken parts of radar once object is destroyed?

Code:

        if ("DunkirkRadar".Equals(shortName) && active)                        //Trigger 1
        {

            GamePlay.gpHUDLogCenter("Dunkirk Radar has been Damaged - Repairs to begin immediately (AT24)");
            GamePlay.gpLogServer(null, "Dunkirk Radar has been Damaged - Repairs to begin immediately (AT24)", new object[] { });
            Timeout(10, () =>
            {
                //  OnStationaryKilled(_stationary.Type.Equals("Radar");

                /*    destroyGroundActor(AiGroundActorType.Radar, 1);
                    destroyGroundActor(AiGroundActorType.RadioBeacon, 1);
                    destroyGroundActor(AiGroundActorType.Unknown, 1);
                    destroyGroundActor(AiGroundActorType.RadioBeamProjector, 1);*/
                GamePlay.gpHUDLogCenter("Dunkirk Radar has been repaired and is fully operational");
                GamePlay.gpLogServer(null, "Dunkirk Radar has been repaired and is fully operational", new object[] { });
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Atag/Channel_Command/Supply/5DunkirkRadar.mis"); // Submission of this type the path correctly                               
                GamePlay.gpGetTrigger(shortName).Enable = false;
            });
        }


FG28_Kodiak 08-06-2012 07:28 AM

I use this to remove statics:
Code:

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


public class Mission : AMission
{

    private static string userdocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    private static string FILE_PATH = userdocpath + @"\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Test\";
    private static string MISSION = FILE_PATH + "StaticTestSub.mis";

    Dictionary<GroundStationary, int> StationaryMisRelation = new Dictionary<GroundStationary, int>();



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

        MissionNumberListener = -1;
    }


    public override void OnMissionLoaded(int missionNumber)
    {
        base.OnMissionLoaded(missionNumber);

        GamePlay.gpLogServer(null, "OnMissionLoaded: {0}", new object[] { missionNumber });

        foreach (GroundStationary gs  in GamePlay.gpGroundStationarys())
        {
            if (!StationaryMisRelation.ContainsKey(gs))
                StationaryMisRelation[gs] = missionNumber;
        }
    }


    private void RemoveStationary(int missionNumber)
    {
        List<GroundStationary> KeysToRemove = new List<GroundStationary>();

        foreach (KeyValuePair<GroundStationary, int> kvp in StationaryMisRelation)
        {
            if (kvp.Value == missionNumber)
            {
                kvp.Key.Destroy();
                KeysToRemove.Add(kvp.Key);
            }
        }


        foreach (GroundStationary groundStationary in KeysToRemove)
        {
            StationaryMisRelation.Remove(groundStationary);
        }
       
    }

    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);

        if (shortName.Equals("MisLoad"))
        {
            GamePlay.gpLogServer(null, "MisLoad: {0}", new object[] { MISSION });
            GamePlay.gpPostMissionLoad(MISSION);
        }


        if (shortName.Equals("Trigger"))
        {
           
            foreach (KeyValuePair<GroundStationary, int> kvp in StationaryMisRelation)
            {
                GamePlay.gpLogServer(null, "Stationary: {0}; MissNr.: {1}", new object[] {kvp.Key.Title, kvp.Value});
            }
        }


        if (shortName.Equals("DeleteTrigger")) // from submission
        {
            GamePlay.gpLogServer(null, "DeleteTrigger MissionNr.: {0}", new object[] { missionNumber });

            RemoveStationary(missionNumber);
        }
    }

}

Explanation:
I store the GroundStationary with the missionNumber in a Dictionary. If a new (sub)mission is loaded i check in OnMissionLoaded if there are new Stationaries created if so i store them in the dictionary with their missionNumber.
If the submission triggers (in this example) the "DeleteTrigger" i remove all statics with this missionNumber.

hc_wolf 08-06-2012 08:29 PM

Thanks Kodiak. A bit of a fiddle around but I have it working perfect now in a bigger mission. I had to duplicate a trigger in Main mission and sub mission to get the result I want otherwise it destroyed everything in the main mission.

Thanks.


All times are GMT. The time now is 02:59 AM.

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