Thank you very much for great explanation! I will be using it in the future.
Currently I am struggling with triggers for my R2 and R3 mission and hope you can advise what I should look at.
I am loading 2 submissions 1_E3_air0.mis , 1_E3_air1.mis randomly.
2nd one is a copied 1st one with aircraft changed from Wellington to Blenheim. Name of airgroup remained the same.
Triggers in submissions are called 1_E3_air and 1_E3_air. Same name now but I tried also checking 1_E3_air0 and 1_E3_air1 in a loop with the same result. The trigger was created in the 1st submission and copied to the 2nd in a notepad.
1_E3_air TPassThrough 1 gb02.07 53073 33421 2000
1_E3_air TPassThrough 1 gb02.07 53073 33421 2000
As a result, the 1st submission trigger does not work at all. The second submission trigger works 2 or 5 times (maybe depending on number of aircraft in the group?)
Questions:
Why the trigger in 1st submission may not wark?
In which cases && active) check must be added?
When GamePlay.gpGetTrigger(shortName).Enable = false; must be edded? Naryv does not use it in some of his examples.
How to make 2nd trigger "work" only once per mission?
Can all triggers have the same name?
When I copy a mission file should I change a name of an airgroup in it by hand?
If I include all the triggers into the host-mission only would they trigger when submission airgroups pass-through?
Code:
public override void OnTrigger(int missionNumber, string shortName, bool active)
{ base.OnTrigger(missionNumber, shortName, active);
string[] attackSector = { "C5", "D4", "E3" }; // sectors attacked
// air missions
#region air missions
string currMissType = "air";
for (int j = 1; j < 3 ; j++) // Army
{
for (int i = 0; i < attackSector.Length ; i++)
{
string str = (j).ToString() + "_" + attackSector[i].ToString() + "_" + currMissType; // +k.ToString(); // + missionType[1].ToString() //string str = i.ToString() + "_" + (j).ToString() + "_gg";
// && active) is this needed?
if (str.Equals(shortName)) // && active) is this needed? // test
{
sendChatMessageTo(-1, str , null); // test msg
if (j == 1) // red win
{
currBonusLoss = allowed109s - min109s;
if (currBonusLoss < 1) currBonusLoss++;
allowed109s = min109s;
ScoreRed += 1;
sendScreenMessageTo(-1, new string[] { "ru" }, "The Allies bombed the Axis' airfield! Limit of available Bf-109E4 is reduced by {0}!", new object[] { currBonusLoss });
sendScreenMessageTo(-1, "Красные разбомбили синий аэродром! Лимит доступных Bf-109E4 снижен на {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, new string[] { "ru" }, "The Allies bombed the Axis' airfield! Limit of available Bf-109E4 is reduced by {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, "ru", "Красные разбомбили синий аэродром! Лимит доступных Bf-109E4 снижен на {0}!", new object[] { currBonusLoss });
// testing
sendScreenAndChatMessageTo( -1, new object[] { currBonusLoss },
"Testing! sendScreenAndChatMessageTo Bf-109E4 is reduced by {0}!",
"Тест! sendScreenAndChatMessageTo Bf-109E4 is reduced by {0}!");
}
else // blue win
{
allowedSpit2s = minSpit2s;
ScoreBlue += 1;
sendScreenMessageTo(-1, new string[] { "ru" }, "The Axis bombed the Allies' airfield! Limit of available Spitfire IIa is reduced by {0}!", new object[] { currBonusLoss });
sendScreenMessageTo(-1, "Синие разбомбили красный аэродром! Лимит доступных Spitfire IIa снижен на {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, new string[] { "ru" }, "The Axis bombed the Allies' airfield! Limit of available Spitfire IIa is reduced by {0}!", new object[] { currBonusLoss });
sendChatMessageTo(-1, "ru", "Синие разбомбили красный аэродром! Лимит доступных Spitfire IIa снижен на {0}!", new object[] { currBonusLoss });
}
// do I need this?
//GamePlay.gpGetTrigger(shortName).Enable = false;
break;
}
}
}
#endregion
}
If you would like to see the complete mission please let me know. But it is a mess now