Jump to content

How to show details of enemy plane damage


Recommended Posts

Posted

For training purposes, it is sometimes interesting to know what damage inflicts on the planes that we engage.
Here is a script allowing to visualize in the chat info window the damage inflicted on airplanes we shoot at.

 

using System;
using maddox.game;
using maddox.game.world;

public class Mission : maddox.game.AMission
{

    public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft Aircraft, AiDamageInitiator DamageFrom, part.NamedDamageTypes WhatDamaged)
    {
     base.OnAircraftDamaged(missionNumber, shortName, Aircraft, DamageFrom, WhatDamaged);
     
     if (DamageFrom.Player != null )
     {
        GamePlay.gpLogServer (null, "{0} hits {1} : {2} \n", new object [] {DamageFrom.Player, shortName, WhatDamaged});//Test
      }
     
    }
}

Copy this code in the "Script" tab ("Edit ->" Script "menu) of the mission. Here is a test mission (right click" save as ")

 

 

613.jpg

 

It works in solo and in multiplayer (if the host uses the script in the mission).
Here is the ingame result :

 

516.jpg

 

Thanks to FG28_Kodiak for this script !
source: http://forum.1cpublishing.eu/showthread.php?t=25337&highlight=convoy

Guest deleted@7076
Posted (edited)

-Deleted-

 

Edited by Varrattu
Posted (edited)

Copy this code in the "Script" tab ("Edit ->" Script "menu) of the mission. Here is a test mission (right click" save as ")

 

Test mission works as described. When script is added to my existing missions AI damage doesn't show in window and I get script errors in log file typically ending like:

... .cs(15,8): error CS1513: } expected

Edited by Dagwoodyt
Posted (edited)

This error  indicates that a '}' is missing in line 15 (of OP code).

 

Probable when you cut and past the code for other missions, leave the last '}' outside the copy, so the above '}' is assumed as the last and line 15 lost their.

 

You can just make copy of "OnAircarftDamaged.cs" of  OK mission and rename with the name of other missions, if this missions have no other script.

 

If mission already have script you need combine both scripts, what - if you are not a C# expert;  is very, very... "fun". ?

 

If use FMB for add the script, after paste the code in script window, right click over and run "Compile", this will show if script have errors, like missing '}'.

 

Edited by Sokol1
Posted (edited)

Thx. Sokol1, works now.

Edited by Dagwoodyt
Posted (edited)
On 9/9/2020 at 6:04 AM, Varrattu said:

Hello, give this tiny script a try....

 

Varratu,

 

Perhaps you can help me with an script.

 

In default "Cliffs of Dover" campaign is used "SayToGroup" for that "impressive" dialog, using the voice samples from Speech folder. Example (last line of code)

 


//$reference Campaign.dll
//-$debug
using System;
using maddox.game;
using maddox.gp;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : maddox.game.campaign.Mission {

    AiActor a1, a2, a4;
    AiAircraft airc1, airc2, airc4;

    public override void OnBattleStarted() {
        base.OnBattleStarted();
        a1 = GamePlay.gpActorByName("0:BoB_RAF_F_FatCat_Early.010");
        a2 = GamePlay.gpActorByName("0:BoB_RAF_F_FatCat_Early.001");
        a4 = GamePlay.gpActorByName("0:BoB_RAF_F_FatCat_Early.011");

        if (a1 == null || a2 == null || a4 == null) {
            System.Console.WriteLine("SCRIPR ERROR: Aircraft not found");
        }

        airc1 = (AiAircraft)a1;
        airc2 = (AiAircraft)a2;
        airc4 = (AiAircraft)a4;

        double initTime = 40.0;
        Timeout(initTime += 5.0, () => {
            airc1.SayToGroup(airc2.AirGroup(), "What_is_that_Where_are_you_two_going");
        });

 

Well I want use this this "SayToGrop" function, but instead a aircraft I want that a vehicle  ("0:1_Chief0" "talk", or more specific play "Ahooga" horn sound. ?

But don't figure how...

 


 a1 = GamePlay.gpActorByName("0:1_Chief0");

 

Since game play only audio samples indexed of Speech folder, I use the "!" (exclamation.ogg)  file - that is now blank (4kb)* for rename "Ahooga" sound, so "Exclamation.ogg" sounds "Ahooga".

 

* For obvious reason.. when someone are reading what sound "!" signal make? :wacko:

Well in game now "!" sounds...  "Ahooga"?

Edited by Sokol1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...