PDA

View Full Version : Problem with objective count



9./JG52 Hans Gruber
Mar-02-2014, 07:45
In need of somebody smarter than me to see the problem.

In Kanalkampf mission point values are assigned to the objectives.



int BlueObjective1 = 10;//Portsmouth Harbor
int BlueObjective2 = 5;//RAF Ventnor CH
int BlueObjective3 = 1;//British Destroyer 1
int BlueObjective4 = 1;//British Merchant 1
int BlueObjective5 = 1;//British Merchant 2
int BlueObjective6 = 1;//British Merchant 3
int BlueObjective7 = 1;//British Merchant 4
int BlueObjective8 = 1;//British Merchant 5
int BlueObjective9 = 1;//British Merchant 6
int BlueObjective10 = 1;//British Merchant 7
int BlueObjective11 = 1;//British Merchant 8
int BlueObjective12 = 1;//British Merchant 9
int BlueObjective13 = 1;//British Merchant 10
int BlueObjective14 = 1;//British Merchant 11
int BlueObjective15 = 1;//British Merchant 12
int BlueObjective16 = 1;//British Merchant 13
int BlueObjective17 = 1;//British Merchant 14
int BlueObjective18 = 1;//British Merchant 15
int BlueObjective19 = 1;//British Merchant 16
int BlueObjective20 = 1;//British Merchant 17
int BlueObjective21 = 1;//British Merchant 18
int BlueObjective22 = 1;//British Merchant 19
int BlueObjective23 = 10;//RAF Tangmere

Then here point values are used to determine winner and end map.


if (InitialBlueObjectiveCount >= 40)// Blue battle Success
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "Blue has Successfully Completed All Objectives!!!", new object[] { });
GamePlay.gpHUDLogCenter("Blue has Successfully Completed All Objectives!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission Ending, Great Job Blue Team!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission Ending, Great Job Blue Team!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to recconect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to recconect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}

One type of target trigger works perfectly. As soon as trigger fires and InitialBlueObjectiveCount increases the mission end process starts if the conditions for victory are met.


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);


if ("UK_Portsmouth".Equals(shortName) && active)
{
InitialBlueObjectiveCount = InitialBlueObjectiveCount + BlueObjective1;
GamePlay.gpHUDLogCenter("AG19.6 - Portsmouth Harbor destroyed!!!");
GamePlay.gpGetTrigger(shortName).Enable = false;
double initTime = 0.0;
Timeout(initTime += 10, () =>
{
GamePlay.gpLogServer(null, "AG19.6 - Portsmouth Harbor destroyed!!!", new object[] { });
Objective_Total_Blue += (Objective_A);
});
}
}

However, with airfield target the mission end sequence does not begin if the conditions are met even though InitialBlueObjectiveCount is being increased. Bomb damage is shown with each explosion and when required kg amount is reached "AJ20.2 - RAF Tangmere destroyed!!!" appears in HUD and chat as coded.


public override void OnBombExplosion(string title, double mass, Point3d pos, AiDamageInitiator initiator, int eventArgInt)
{

base.OnBombExplosion(title, mass, pos, initiator, eventArgInt);

foreach (AiAirport ap in AirfieldTargets.Keys)
{
if (AirfieldTargetsDamage[ap] >= AirfieldTargets[ap])
{//damage greater than or equal to that required to knock out so no need to add or further process

}
else
{
//Damage not greater than or equal to so need check if bomb fell inside radius and if so increment up
if (ap != null & ap.Pos().distance(ref pos) <= ap.FieldR())
{
AirfieldTargetsDamage[ap] = AirfieldTargetsDamage[ap] + mass;
GamePlay.gpHUDLogCenter(AirfieldTargetsName[ap] + " is hit with " + AirfieldTargetsDamage[ap] + "kg of bombs");
if ((AirfieldTargetsDamage[ap] >= AirfieldTargets[ap]) && (AirfieldTargetsName[ap].Contains("Tangmere")))
{
LoadAirfieldSpawns(); //loads airfield spawns and removes inactive airfields.
InitialBlueObjectiveCount = InitialBlueObjectiveCount + BlueObjective23;
GamePlay.gpHUDLogCenter("AJ20.2 - RAF Tangmere destroyed!!!");
double initTime = 0.0;
Timeout(initTime += 10, () =>
{
GamePlay.gpLogServer(null, "AJ20.2 - RAF Tangmere destroyed!!!", new object[] { });
Objective_Total_Blue += (Objective_W);
});
}

}

}
}
}

In summary blue needs 40 points to win map. The point values of each target are shown above. If all objectives are destroyed before Tangmere the mission fails to end. If even a single ship is destroyed after Tangmere then the game realizes that InitialBlueObjectiveCount >= 40 and begins the process to end the map.

It would seem that the "InitialBlueObjectiveCount = InitialBlueObjectiveCount + BlueObjective23;" statement for the Tangmere objective is either not happening until another event increases InitialBlueObjectiveCount or InitialBlueObjectiveCount >= 40 is not being checked after Tangmere is destroyed.

Anybody who can offer a solution to this it would be appreciated and I offer a free game of their choice from the list below as bounty.

BATMAN: ARKHAM ORIGINS™ PC DIGITAL EDITION (Redeemed through Steam)
ASSASSIN’S CREED: IV BLACK FLAG (Redeemed through Uplay)
TOM CLANCY'S SPLINTER CELL BLACKLIST (Redeemed through Uplay)

SoW Reddog
Mar-02-2014, 10:10
Where is the if objectivecount statement? If it's in ontrigger, then that will be your problem, as there's no trigger being fired. Move it to tick game if it is.

9./JG52 Hans Gruber
Mar-02-2014, 12:54
Yes that works but then the end mission process is spammed with every tick since InitialBlueObjectiveCount is always >= assigned value.



public override void OnTickGame()
{
Tick_Mission_Time = 480000 - Time.tickCounter();
var Mission_Time = Tick_Mission_Time / 2000;
TimeSpan Convert_Ticks = TimeSpan.FromMinutes(Mission_Time);
string Time_Remaining = string.Format("{0:D2}:{1:D2}:{2:D2}", Convert_Ticks.Hours, Convert_Ticks.Minutes, Convert_Ticks.Seconds);

if (Time.tickCounter() % 30000 == 1000)
{
GamePlay.gpLogServer(null, "Completed Red Objectives:", new object[] { });
Timeout(10, () => GamePlay.gpLogServer(null, (Objective_Total_Red), new object[] { }));
///Timeout(11, () => GamePlay.gpLogServer(null, " " + TotalBlueShipsDestroyed.ToString() + " Ships of 4,", new object[] { }));
Timeout(12, () => GamePlay.gpLogServer(null, "Completed Blue Objectives:", new object[] { }));
Timeout(15, () => GamePlay.gpLogServer(null, (Objective_Total_Blue), new object[] { }));
Timeout(16, () => GamePlay.gpLogServer(null, " " + TotalRedShipsDestroyed.ToString() + " Ships of 20 destroyed,", new object[] { }));
Timeout(17, () => GamePlay.gpLogServer(null, "Time Remaining In Mission: " + Time_Remaining, new object[] { }));
}


if (InitialBlueObjectiveCount >= 40)// Blue battle Success
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "Blue has Successfully Completed All Objectives!!!", new object[] { });
GamePlay.gpHUDLogCenter("Blue has Successfully Completed All Objectives!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission Ending, Great Job Blue Team!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission Ending, Great Job Blue Team!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to recconect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to recconect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}

if (InitialRedObjectiveCount >= 40)// Red battle Success
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "Red has Successfully Completed All Objectives!!!", new object[] { });
GamePlay.gpHUDLogCenter("Red has Successfully Completed All Objectives!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission Ending, Great Job Red Team!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission Ending, Great Job Red Team!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to recconect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to recconect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}


if (Time.tickCounter() == 480000)// Mission Time Exceeded.
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "The match ends in a tie! Objectives still left for both sides!!!", new object[] { });
GamePlay.gpHUDLogCenter("The match ends in a tie! Objectives still left for both sides!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission is restarting soon!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission is restarting soon!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to reconnect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to reconnect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}

}
}

SoW Reddog
Mar-02-2014, 13:29
OK. That's easily solved.

Add in a new variable at the start of the mission

public bool BlueWon = false;



public override void OnTickGame()
{
Tick_Mission_Time = 480000 - Time.tickCounter();
var Mission_Time = Tick_Mission_Time / 2000;
TimeSpan Convert_Ticks = TimeSpan.FromMinutes(Mission_Time);
string Time_Remaining = string.Format("{0:D2}:{1:D2}:{2:D2}", Convert_Ticks.Hours, Convert_Ticks.Minutes, Convert_Ticks.Seconds);

if (Time.tickCounter() % 30000 == 1000)
{
GamePlay.gpLogServer(null, "Completed Red Objectives:", new object[] { });
Timeout(10, () => GamePlay.gpLogServer(null, (Objective_Total_Red), new object[] { }));
///Timeout(11, () => GamePlay.gpLogServer(null, " " + TotalBlueShipsDestroyed.ToString() + " Ships of 4,", new object[] { }));
Timeout(12, () => GamePlay.gpLogServer(null, "Completed Blue Objectives:", new object[] { }));
Timeout(15, () => GamePlay.gpLogServer(null, (Objective_Total_Blue), new object[] { }));
Timeout(16, () => GamePlay.gpLogServer(null, " " + TotalRedShipsDestroyed.ToString() + " Ships of 20 destroyed,", new object[] { }));
Timeout(17, () => GamePlay.gpLogServer(null, "Time Remaining In Mission: " + Time_Remaining, new object[] { }));
}


if (InitialBlueObjectiveCount >= 40 && !BlueWon)// Blue battle Success
{
BlueWon = true;
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "Blue has Successfully Completed All Objectives!!!", new object[] { });
GamePlay.gpHUDLogCenter("Blue has Successfully Completed All Objectives!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission Ending, Great Job Blue Team!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission Ending, Great Job Blue Team!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to recconect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to recconect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}

if (InitialRedObjectiveCount >= 40)// Red battle Success
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "Red has Successfully Completed All Objectives!!!", new object[] { });
GamePlay.gpHUDLogCenter("Red has Successfully Completed All Objectives!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission Ending, Great Job Red Team!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission Ending, Great Job Red Team!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to recconect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to recconect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}


if (Time.tickCounter() == 480000)// Mission Time Exceeded.
{
Timeout(10, () =>
{
GamePlay.gpLogServer(null, "The match ends in a tie! Objectives still left for both sides!!!", new object[] { });
GamePlay.gpHUDLogCenter("The match ends in a tie! Objectives still left for both sides!!!");
});
Timeout(30, () =>
{
GamePlay.gpLogServer(null, "Mission is restarting soon!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission is restarting soon!!!");
});
Timeout(60, () =>
{
GamePlay.gpLogServer(null, "Server Restarting in 1 minute!!!", new object[] { });
GamePlay.gpHUDLogCenter("Server Restarting in 1 minute!!!");
});
Timeout(120, () =>
{
GamePlay.gpLogServer(null, "Mission ended. Please wait 2 minutes to reconnect!!!", new object[] { });
GamePlay.gpHUDLogCenter("Mission ended. Please wait 2 minutes to reconnect!!!");
});
Timeout(125, () =>
{
Process.GetCurrentProcess().Kill();
});
}

}
}

9./JG52 Hans Gruber
Mar-02-2014, 17:54
You beautiful bastard. Fixed for blue & red. PM me your game choice. :salute:

SoW Reddog
Mar-03-2014, 02:35
Well I've never been called that before! :D

Glad it's fixed. I'll reply to your pm later today.

Kling
Mar-03-2014, 04:36
You guys should create an online missions/campaign thing together that are always based on each other and dependant on each other ;)

The end result of one mission will decide how the next mission starts. Pretty much like Reddogs mission that is still under construction...

ATAG_Lolsav
Mar-04-2014, 16:09
Hi

Been messing around with this and i might have found a minor bug.

Reddog, on the declaration


Tick_Mission_Time = 480000 - Time.tickCounter();

isnt missing something? could it be " int Tick_Mission_Time = "

SoW Reddog
Mar-04-2014, 16:17
Lolsav, if you look at that snippet in isolation then yes, but in this example the variable is declared previously and not quoted here.

ATAG_Lolsav
Mar-04-2014, 16:28
Well im just a script vampire and im trying to reuse what has alredy been working and proven to do well :)

SoW Reddog
Mar-04-2014, 17:03
Well keep going with it.