![]() |
|
|
|
#1
|
|||
|
|||
|
Won't that leave the AI in control for 60 seconds, rather than having it glide into the ground? Really, the code should be ran instantly, and it should disable AI control instead of simply removing the aircraft--assuming that's currently possible.
|
|
#2
|
|||
|
|||
|
This sample script made for fun disables player controls. Maybe someone can use it to disable AI controls for say 10 minutes before destroying AI
Code:
using System;
using maddox.game;
using maddox.game.world;
public class Mission: maddox.game.AMission
{
/ / Override the method that is invoked when some of the planes will take off ...
public override void OnAircraftTookOff (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff (missionNumber, shortName, aircraft); / / call the base method (you never know ...)
if (GamePlay.gpPlayer ()! = null) / / check if we have a player.
{
if (GamePlay.gpPlayer (). Place ()! = null) / / check that the player is sitting somewhere and not hanging out on the rag.
{
if (aircraft.Name (). Equals (GamePlay.gpPlayer (). Place (). Name ())) / / if the plane took off - a player, then ...
{
aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); / / ... disables elevators ...
aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); / / ... aileron ...
aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); / / ... rudder.
/ / Have a nice flight!
}
}
}
}
}
Last edited by Ataros; 04-26-2011 at 08:16 AM. |
|
#3
|
||||
|
||||
|
Quote:
Yes, you can disable the controls, but trimmed plane can happily fly even without working controls. What I want to say: disabling the controls does not guarantee a quick crash. Extending despawn timeout can lead to great clutter, i.e. when player presses "Create" multiple times. |
|
#4
|
|||
|
|||
|
... my head hurts trying to understand this..
Does anyone fancy writing a fuckwits guide to all this, err sorry i mean a dummies guide? It would be very much appreciated, i'd buy the 1st round or virtual beers! I'm keen to create MP missions but trying to gain the level of understanding needed from these forums and google translations is rather daunting. And i suspect waiting for an official manual would be foolish, considering the flight manual produced. But thanks for all the help provided here, it is appreciated.. just a bit confusing for a new mission builder. |
|
#5
|
|||
|
|||
|
Quote:
This is a sample script to create a small 'campaign' containing a main mission and 3 sub-missions. Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g. C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\ Scripts have to be saved with .cs extension and have the same name as the main mission. Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs. Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder): C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\ Create and edit 3 missions you want to be loaded into the main mission with FMB. Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis. That's it. In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , then edit 3 filepaths in this file. e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission. * Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map). The text in this example is visible to both sides for simplicity. You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand. Download link http://www.microsoft.com/express/Dow...2010-Visual-CS All text after // marks are comments describing what the script does. You may play your mission in MP or as a SP mission if you create a passworded server. I hope to put up some missions using this script to Repka server soon. Code:
/****
* Brief startup guide to scripting.
* This is a sample script to create a small 'campaign' containing a main mission and 3 sub-missions.
*
* Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g.
* C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
* Scripts have to be saved with .cs extension and have the same name as the main mission.
* Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs.
* Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder):
* C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
* Create and edit 3 missions you want to be loaded into the main mission with FMB.
* Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis.
* That's it.
*
* In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , than edit 3 filepaths in the script file.
* e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission. *
*
* Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map).
* The text in this example is visible to both sides for simplicity.
*
* You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand.
* Download link http://www.microsoft.com/express/Downloads/#2010-Visual-CS
*
* All text after // marks are comments describing what the script does.
* You may play your mission in MP or as a SP mission if you create a passworded server.
* Have fun! and S! from 3GIAP
*
* Feel free to delete all the comments above and including this line from this file. ****/
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
{
public override void OnTickGame()
{
// loads the 1st sub-mission in 10 min and repeates it every 60 min.
if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
// pls. note!!! the 1st figure above must be always larger than 2nd!
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis");
// prints message on screen after mission load
GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");
// prints message on screen in 10 minutes / 600 seconds
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
});
// prints message on screen in 5 minutes / 300 seconds
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
});
}
// loads the 2nd sub-mission, etc. the same way
if (Time.tickCounter() % 108000 == 54000) // 108000 = 60 min repeat, 54000 = 30 min delay.
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission2.mis");
GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission2 10 min message!");
});
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Mission2 15 min message!");
});
}
// loads the 3rd sub-mission
if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission3.mis");
GamePlay.gpHUDLogCenter("Mission3.mis loaded!");
double initTime = 0.0;
Timeout(initTime += 600, () =>
{
GamePlay.gpHUDLogCenter("Mission3 10 min message!");
});
Timeout(initTime += 300, () =>
{
GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
});
}
}
}
Last edited by Ataros; 10-14-2011 at 09:03 AM. |
|
#6
|
|||
|
|||
|
Ataros -
![]() Thanks for all the info here.. i'll try and get my head around this over the weekend, your help is very much appreciated. |
|
#7
|
|||
|
|||
|
The above script runs on Repka DS #1 server ATM loading 5 smaller missions into main mission with various time-cycles. Check it out.
|
|
#8
|
|||
|
|||
|
Hi all, and sorry Klem, I can´t help you...
I started now with my attempt to get familar with scripting and C#... ![]() I read through this thread a several times and copied some samples of the outlined scripts. The problem at hand now, is that I want to include a script in the submissions, which will be loaded into a main, basic-map. This submission script shall contain Sec 1- the trigger messages, Sec 2-the instruction messages for new players and players which just took off (WIP:Message shall only be shown, if trigger is not activated yet) Sec 3- a count of trigger states, so very time a victory-trigger is set to true a counter raises the number for the side, which activated the trigger Sec 4- clean up procedure at a certain time from begin of submission, removing all AI loaded into the basic map with the submission Following questions appeared now at this stage: (A) I already found out how to theoretically get the trigger messages running, still have to get it right, how to show the message only if the otherside (red/blue) has not activated their trigger yet. Is thiss possible by something like this? if (<Trigger Red won> == active || <Trigger Blue won> == acitve) <message red won> (B) How do I get rid off of all the AI loaded on the basic map, when the submission has done its job? I wanted to try following script sample to remove the AI after an hour into the submission: //////////////// Section 4: get rid off all AI loaded with submission //mod-start by SNAFU -> ZIEL: nach 1h AI-Flieger entfernen public override void OnTickGame() { double initTime; if (Time.tickCounter() % 108000 == 10799) // 108000=1h { //mod-end by SNAFU foreach (int army in GamePlay.gpArmies()) { foreach (AiAirGroup group in GamePlay.gpAirGroups(army)) { if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) /// <- delete line to kill all { AiActor[] members = group.GetItems(); for (int i = members.Length - 1; i > -1; i--) { (members[i] as AiAircraft).Destroy(); } } } foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army)) { if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) /// <- delete line to kill all { AiActor[] members = group.GetItems(); for (int i = members.Length - 1; i > -1; i--) { (members[i] as AiGroundActor).Destroy(); } } } } } (C) I now loaded a briefing message into the basic map, so every player joining and taking off, will be briefed into the actual ongoing submission. The basic map listens to all events introduced with the submissions, ok. But... If the the submission is over, how does the main script notice the that the submissions states, messages (f.e. the briefing messages) are not valid anymore? Ist that the "puplic override" I see everywhere? Here the template for the submission script and sorry for all the silly questions: ![]() Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
//////////////////////////////////////////////////////////////////////////////////////
///////////Section 1: Trigger messages
///to copy into
/////////////////////////////////////////////////Section 3: Briefing for new players
///WIP if (<Trigger missions success red/blue> = false) /////WIP: Trigger Condition for Mission red/blue != true
{
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = actor as AiAircraft;
if (aircraft != null)
switch (aircraft.Army())
{
case 1:
if (aircraft.Type() == AircraftType.Bomber) /////////////Nachricht für neue Spieler
{ GamePlay.gpHUDLogCenter(new Player[] {player},"Red Bomber Task"); } /////////roter Bomber
else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Red Fighter Task"); } ///////////roter Jäger
break;
case 2:
if (aircraft.Type() == AircraftType.Bomber)
{ GamePlay.gpHUDLogCenter(new Player[] { player }, "Blue Bomber Task"); } ////////////blauer Bomber
else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Blue Fighter Task"); } //////////// blauer Jäger
break;
}
}
public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff(missionNumber, shortName, aircraft);
if (GamePlay.gpPlayer().Place() != aircraft)
return;
switch (aircraft.Army())
{
case 1:
if (aircraft.Type() == AircraftType.Bomber) /////////////Nachricht für neue Spieler
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber Task"); } /////////roter Bomber
else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Fighter Task"); } ///////////roter Jäger
break;
case 2:
if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber))
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Blue Bomber Task"); } ////////////blauer Bomber
else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber Task"); } //////////// blauer Jäger
break;
}
}
///WIP }
//////////////////////////////////////////////////////////////////////////////////////
//////////////// Section 3: Trigger count for overall win condition
// still no idea
//////////////////////////////////////////////////////////////////////////////////////
//////////////// Section 4: get rid off all AI loaded with submission
//mod-start by SNAFU -> ZIEL: nach 1h AI-Flieger entfernen
public override void OnTickGame()
{
double initTime;
if (Time.tickCounter() % 108000 == 10799) // 108000=1h
{
//mod-end by SNAFU
foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber)) /// <- delete line to kill all
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiAircraft).Destroy();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber)) /// <- delete line to kill all
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiGroundActor).Destroy();
}
}
}
}
}
Last edited by SNAFU; 06-21-2011 at 03:45 PM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|