PDA

View Full Version : III.KG1 Ju88 Campaign Script help request


dflion
10-01-2011, 05:07 AM
I have worked out the basic script trigger types for each mission (there are three basic types) - here they are.

Mission 1. 'Group to pass through twice and land at the same airfield' (1 mission)
Missions 2 and 3. 'Group to pass through once and land at different airfield' (2 missions)
Missions 4 to 12. 'Group to pass through twice and land at same airfield' + 'target ground destroyed'. (9 missions)

All missions are to be linked to the next one, with a 'successfully completed' or 'failed' scripting.

My original script is shown below

//$reference Campaign.dll
//-$debug
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
using System.Diagnostics; // for Stopwatch timer


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

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

public override void OnTrigger(int missionNumber, string shortName, bool active) {
if ("trigger01".Equals(shortName) && active) {

AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, "KG1_Ju88_01"));
if (action != null)
action.Do();
action = GamePlay.gpGetAction(ActorName.Full(missionNumber, "KG1_Ju88_02"));
if(action != null)
action.Do();


GamePlay.gpGetTrigger(shortName).Enable = false;
}
}

public override bool IsMissionListener(int missionNumber) {
return true;
}


private void checkLanded(AiAircraft aircraft) {
if (GamePlay.gpPlayer().Place() != aircraft)
return;
GamePlay.gpHUDLogCenter("Press Esc to end mission.");
}

public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) {
checkLanded(aircraft);
}

public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) {
checkLanded(aircraft);
}

}

More campaign mission detail shown below

1. 26th Jun 1940 'Montdidier' -training mission
2. 27th Jun 1940 'Transfer to Rosieres-en-Santerre' - positioning/training flight
3. 2nd Jul 1940 'Caen-Carpiquet' - positioning flight
4. 2nd Jul 1940 'Minelaying' - night first combat mission
5. 3rd Jul 1940 'Ford' - night pattern bombing mission
6. 13th Jul 1940 'We bomb Portsmouth' - day pattern bombing mission
7. 25th Jul 1940 'Convoy Attack' - day dive bombing mission
8. 28th Jul 1940 'The Thames Estuary' - day pattern bombing mission
9. 4th Aug 1940 'Uphavon' -night pattern bombing mission
10. 12th Aug 1940 'Ventor' - day dive bombing mission
11. 30th Aug 1940 'We bomb Biggin Hill' day pattern bombing mission
12. 7th Sep 1940 'The London Docks' day pattern bombing mission



I would really appreciate some help with this from a script writer. Thankyou.

DFLion

FG28_Kodiak
10-01-2011, 07:05 AM
Do you need a complete script or just little hints what to do?

dflion
10-01-2011, 08:04 AM
Thanks FG28_Kodiak,
As I am in the steep learning curve in how to do 'scripting', I would like a complete script. I appreciate your help and it will help me to learn more about scripting in my next campaigns.

If you need to see the complete campaign, contact me privately through the forum.

DFLion

dflion
10-06-2011, 07:05 AM
I have just finished scripting my 'Battle of France' campaign and it seems to be working very well. The only thing that doesn't work is that if you are successful in a mission, then have to leave the game (for some reason), when you come back to the (game) campaign it doesn't start where you left it????

My KG1.111_Ju88 campaign is still not working properly? Need some help 'boys and girls'?

DFLion

FG28_Kodiak
10-06-2011, 07:55 AM
At the moment i about to finish a checkAirfield Routine:


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

public class Mission : AMission
{
AiAirport PlayerStartAirport;
AiAirport PlayerEndAirport;
AiAircraft PlayerAircraft;

internal AiAirport getNearestAirfield(Player player)
{
AiAirport NearestAirfield = null;
AiAirport[] airports = GamePlay.gpAirports();
Point3d PlayerStartPos = player.Place().Pos();

if (airports != null)
{
foreach (AiAirport airport in airports)
{
if (NearestAirfield != null)
{
if (NearestAirfield != null)
if (NearestAirfield.Pos().distance(ref PlayerStartPos) > airport.Pos().distance(ref PlayerStartPos))
NearestAirfield = airport;
}
else NearestAirfield = airport;
}
}
return NearestAirfield;
}


internal AiAirport getNearestAirfield(AiWayPoint waypoint)
{
AiAirport NearestAirfield = null;
AiAirport[] airports = GamePlay.gpAirports();
Point3d WaypointPos = waypoint.P;

if (airports != null)
{
foreach (AiAirport airport in airports)
{
if (NearestAirfield != null)
{
if (NearestAirfield != null)
if (NearestAirfield.Pos().distance(ref WaypointPos) > airport.Pos().distance(ref WaypointPos))
NearestAirfield = airport;
}
else NearestAirfield = airport;
}
}
return NearestAirfield;
}


internal bool checkAirfield(Player player, AiAirport airport, double maxdistance)
{
Point3d PlayerPos = player.Place().Pos();
GamePlay.gpLogServer(null, "Distanz zum Flugplatz {0}", new object[] {airport.Pos().distance(ref PlayerPos)}); //test
if (airport.Pos().distance(ref PlayerPos) < maxdistance)
return true;
else return false;
}


public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionNumberListener = -1;
}


private void checkLanded(AiAircraft aircraft)
{
if (GamePlay.gpPlayer().Place() != aircraft)
return;
}


public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
if (aircraft.Player(0) != null)
{

if (checkAirfield(aircraft.Player(0) , PlayerStartAirport, 2000.0))
GamePlay.gpHUDLogCenter("Mission Successfull");
}
}


public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
if (aircraft.Player(0) != null)
{

if (checkAirfield(aircraft.Player(0), PlayerStartAirport, 2000.0))
GamePlay.gpHUDLogCenter("Mission Successfull");
}
}



public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

if (PlayerStartAirport== null)
PlayerStartAirport = getNearestAirfield(player);


AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay();

int i = Wp.Length;

if (i > 0)
{
AiWayPoint EndPoint = Wp[i - 1];

if (PlayerEndAirport == null)
PlayerEndAirport = getNearestAirfield(EndPoint);
}
else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() });
}
}


Should work but need some tests, above checks if the players StartAirport is the same he landed. Then you should get the message "Mission Successfull"

This

AiWayPoint[] Wp = GamePlay.gpPlayer().Place().Group().GetWay();

int i = Wp.Length;

if (i > 0)
{
AiWayPoint EndPoint = Wp[i - 1];

if (PlayerEndAirport == null)
PlayerEndAirport = getNearestAirfield(EndPoint);
}
else GamePlay.gpLogServer(null, "No Waypoints for this Airgroup {0}", new object[] { GamePlay.gpPlayer().Place().Group().Name() });

Looks for the nearest Airfield at last Player Waypoint. But i ve not integrated it in the victory conditions at time.

dflion
10-07-2011, 06:35 AM
These two script routines look very promising Kodiak. I will wait until you test them further. Thankyou again.
DFLion