![]() |
|
|
|
#1
|
|||
|
|||
|
An other way to get the Enemy location via script.
In this script i check the distance between red Airgroups and blue Airgroups. And if it lower as a given value, there will a Voice Message being generated to the ally Airgroups which are in range to the enemy. The script is not fully tested yet, i am to busy at the moment (home renovation ). Feel free to expand it, the voice files (use the filename without .ogg) are located in ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\bob\speech, you can add for example the type of the Enemy Aircrafts, their Numbers etc. The timedelay between the checks should be larger as in my example to avoid overlaping of the messages.Code:
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
public void sendMessagesToAirgroup(AiAirGroup from, double maxDistance)
{
AiAirGroup[] EnemyAirgroups;
Point3d StartPos = new Point3d(from.Pos().x, from.Pos().y, 1.0);
EnemyAirgroups = GamePlay.gpAirGroups((from.Army() == 1) ? 2 : 1);
int i = 0;
foreach (AiAirGroup aag in EnemyAirgroups)
{
Point3d enemyPosition = new Point3d(aag.Pos().x, aag.Pos().y, 1.0);
if (from.Pos().distance(ref enemyPosition) < maxDistance)
{
string sectorName = GamePlay.gpSectorName(aag.Pos().x, aag.Pos().y);
string[] splittet = sectorName.Split(',');
string alpha = splittet[0];
string number = "n" + splittet[1];
AiAircraft LeaderPlane = (from.GetItems()[0] as AiAircraft);
Timeout(i, () =>
{
(LeaderPlane as AiAircraft).SayToGroup(from as AiAirGroup, "Enemy_planes");
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, "In_square");
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, alpha);
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, number);
});
i += 2;
}
}
}
public override void OnTickGame()
{
base.OnTickGame();
if (Time.tickCounter() % 600 == 299)
{
foreach(AiAirGroup aag in GamePlay.gpAirGroups(1))
sendMessagesToAirgroup(aag, 100000.0);
}
}
}
Last edited by FG28_Kodiak; 04-08-2012 at 03:15 PM. |
|
#2
|
|||
|
|||
|
That looks interesting, Kodiak. Do I just copy that script over existing one? Do I need any extra functions to invoke messages? Where do I edit distaff value between Airgroups? .... If You answer I will test it as soon as possible...
__________________
![]() Asus P6T V2 Deluxe, I7 930, 3x2 GB RAM XMS3 Corsair1333 Mhz, Nvidia Leadtek GTX 470, Acer 1260p screen projector, Track IR 4 OS ver5, Saitek Pro Flight Rudder, Saitek X52, Win 7 x64 ultimate |
|
#3
|
|||
|
|||
|
Only copy the sendMessagesToAirgroup to your code, in OnTickGame you will see the example how to use it
sendMessagesToAirgroup(aag, 100000.0); bold is the distance. |
|
#4
|
|||
|
|||
|
Some more radar speech code that might be useful. I use sayMessageTo to voice to everyone in the army, not just the airgroup, and have converted altitude to use 'angels' & 'metres' (depending on the army) with custom functions.
Interestingly, both (actor as AiAircraft).getParameter(part.ParameterTypes.Z_Alt itudeMSL, -1); and (actor as AiAircraft).getParameter(part.ParameterTypes.Z_Alt itudeAGL, -1); both fail to get the airgroup altitude in a multi-player server environment, so you need to use the Pos().z & convert the z offset to metres. Code removed by author
__________________
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 Last edited by salmo; 01-12-2013 at 02:07 PM. |
|
#5
|
||||
|
||||
|
Now this stuff looks very promising.
I'm going to crack open VS express and have a bigger look. I can't write the stuff but adapting it may be easier. |
|
#6
|
|||
|
|||
|
Kodiak thats great. Were gonna give it a whirl on our server today. I have some ideas for expansion. Could there be some kind of delay between requesting the information and recieving it, say 4 mins? This would simulate the request going to and from the lines of communication. Also. What if some radars are knocked out or damaged? Can this be simulated also?
P.S. I know how you feel with the renovation, Ive been doing it for 4 months now. It will be finished this week. What a grind. |
|
#7
|
|||
|
|||
|
you wanna ask the operators with the mission menu? and than after 4min you will get the response? This is possible without problem.
Okay for clearance, when we use "radars" will you give the messages to the Airgroups in range of a spezific radarstation or to all. So if you hit the 'radarbutton' then you get Information of all Enemies Airgoups in range of any available radarstation or only from this you are in Range? |
|
#8
|
|||
|
|||
|
i gave it a go : this is my script
PHP Code:
PHP Code:
__________________
![]() Asus P6T V2 Deluxe, I7 930, 3x2 GB RAM XMS3 Corsair1333 Mhz, Nvidia Leadtek GTX 470, Acer 1260p screen projector, Track IR 4 OS ver5, Saitek Pro Flight Rudder, Saitek X52, Win 7 x64 ultimate |
|
#9
|
|||
|
|||
|
Yepp:
Added if (EnemyAirgroups == null) return; to method sendMessagesToAirgroup and if (GamePlay.gpAirGroups(1) != null) in OnTickGame to avoid exception Code:
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using maddox.GP;
public class Mission : AMission
{
public void sendMessagesToAirgroup(AiAirGroup from, double maxDistance)
{
AiAirGroup[] EnemyAirgroups;
Point3d StartPos = new Point3d(from.Pos().x, from.Pos().y, 1.0);
EnemyAirgroups = GamePlay.gpAirGroups((from.Army() == 1) ? 2 : 1);
if (EnemyAirgroups == null) return;
int i = 0;
foreach (AiAirGroup aag in EnemyAirgroups)
{
Point3d enemyPosition = new Point3d(aag.Pos().x, aag.Pos().y, 1.0);
if (from.Pos().distance(ref enemyPosition) < maxDistance)
{
string sectorName = GamePlay.gpSectorName(aag.Pos().x, aag.Pos().y);
string[] splittet = sectorName.Split(',');
string alpha = splittet[0];
string number = "n" + splittet[1];
AiAircraft LeaderPlane = (from.GetItems()[0] as AiAircraft);
Timeout(i, () =>
{
(LeaderPlane as AiAircraft).SayToGroup(from as AiAirGroup, "Enemy_planes");
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, "In_square");
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, alpha);
});
Timeout(i += 2, () =>
{
LeaderPlane.SayToGroup(from, number);
});
i += 2;
}
}
}
public override void OnTickGame()
{
base.OnTickGame();
if (Time.tickCounter() % 600 == 299)
{
if (GamePlay.gpAirGroups(1) != null)
foreach(AiAirGroup aag in GamePlay.gpAirGroups(1))
sendMessagesToAirgroup(aag, 100000.0);
}
}
}
Last edited by FG28_Kodiak; 04-08-2012 at 08:28 PM. |
|
#10
|
|||
|
|||
|
Quote:
![]() How would you ask the radar?
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|