PDA

View Full Version : Send message on grouped active triggers


hc_wolf
03-26-2012, 11:50 PM
Hi,

I am looking to have a message sent every few minutes that will send a message saying if the Objective is complete or not.

Currently if the 3 Bool Triggers are activated as a group then the objective is complete.

Is there a way in Ticktime to check that these are active or not and send a message to the Hud that the Objective is "Complete" or "Not Complete"


bool BGTarget2 = false; //German Bomber group 1 of 6
bool BGTarget2_1 = false; //German Bomber group 2 of 6
bool BGTarget2_2 = false; //German Bomber group 3 of 6





/*-----------Show scores about every 10 minutes----------*/
public override void OnTickGame()
{
if (Time.tickCounter() % 18 == 17)
{
GamePlay.gpLogServer(null, "Team scores - RAF {0}: LW {1}", new object[] { ScoreRed,ScoreBlue });
base.OnTrigger(missionNumber, shortName, active);

if (("BGTarget2".Equals(shortName) && active) && ("BGTarget2_1".Equals(shortName) && active) && ("BGTarget2_2".Equals(shortName) && active))
//if ((BGTarget2 && BGTarget2_1 && BGTarget2_2) = true);
Timeout(10, () =>
{
GamePlay.gpHUDLogCenter("Red Objective 11 Completed!!!");
}
}

Smokeynz
03-27-2012, 12:43 AM
I don't think you can set the ticktimer with the 18 == 17 followed by the ontrigger as the ontrigger is an internal event based reaction, polling with a timer you will miss the event.

you are relying on a time based system to look for change, where really you may want a event based system or both.

I would excecute a separate private void to test for your true and false conditons with the timer. Then have the ontrigger as standard setup waiting for the events to set up the true and false condition, destroyed etc what ever the trigger type. You could also execute the private void test upon true false setting at the ontrigger.
Actually note in the other thread about point2D where I setup true and false test in the ontrigger, but call a private void which in this case can be called by 3 event types. Timer, ontrigger and onplaceenter

I would also test the triggers themselves separately, each sets an individual true or false, then test the those true and falses, rather than try and group the triggers .
Also place a test message (that you text out later) in each trigger and stage, so you know where your code is getting up too.

hc_wolf
03-27-2012, 02:14 AM
I had a think about it. I do have the BOOL's for each trigger to check.

You think this would work? I am checking each Bool that they are True. Then reseting htem to False if they are true and sending out the messges.

I have OnTrigger set and that works fine. I am hoping the code below will give me the update every 10 mins that the objective is complete IF the BOOL's are True.


public class Mission : AMission
{
bool BGTarget2 = false; //German Bomber group 1 of 6
bool BGTarget2_1 = false; //German Bomber group 2 of 6
bool BGTarget2_2 = false; //German Bomber group 3 of 6

public override void OnTickGame()
{
base.OnTickGame();
{

if (Time.tickCounter() % 18000 == 17990) //check every 10 mins
//if (Time.tickCounter() % 68 == 1) ///Check every 2 seconds
{

if ((BGTarget2 == true) && (BGTarget2_1 == true) && (BGTarget2_2 == true))
{
BGTarget2 = false;
BGTarget2_1 = false;
BGTarget2_2 = false;
GamePlay.gpLogServer(null, "Team scores - RAF {0}: LW {1}", new object[] { ScoreRed,ScoreBlue });
GamePlay.gpLogServer(null, "Team Objectives Completed - RAF {0} of 2: LW {1} of 2", new object[] { ScoreRed,ScoreBlue });
Timeout(10, () =>
{
GamePlay.gpHUDLogCenter("Red Objective 11 Completed!!!");
});
}
}

}
}
}

FG28_Kodiak
03-27-2012, 04:28 AM
Should work ;)

Btw. You use bools so its not nessesary to write:
if ((BGTarget2 == true) && (BGTarget2_1 == true) && (BGTarget2_2 == true))
you could also use:
if (BGTarget2 && BGTarget2_1 && BGTarget2_2)

hc_wolf
03-27-2012, 05:02 AM
I am such a bool!

Cheers Kodiak

Seems to run through MS Visual Express with out errors also. Thanks

hc_wolf
03-27-2012, 05:11 AM
Question if anyone can help. I am using MS Visula express c#

When I click 'Start Debugging' It runs but I get an error warning

'A Project with an Output Type of Class Library cannot be started directly.

In order to debug this, add an executable project to this solution which references the library project. Set the executable project as the Startup Project."

I am not sure how to do this. I gather it wants the Launcher.exe which I have, but unsure how to adde it.

If it is to hard to explain the steps don't waist your time. I can get by. Thanks :D

FG28_Kodiak
03-27-2012, 05:19 AM
You create a DLL a DLL must be called by a programm to work. A DLL is never standalone.
BTW the debugger is worthless in this situation, you cannot run it in Cliffs of Dover. :(

hc_wolf
03-27-2012, 05:48 AM
You create a DLL a DLL must be called by a programm to work. A DLL is never standalone.
BTW the debugger is worthless in this situation, you cannot run it in Cliffs of Dover. :(

LOL well that answers that. Won't waste my time. Cheers buddy!

FG28_Kodiak
03-27-2012, 10:00 AM
Btw a other aproach to the problem, with counters:

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

public class Mission : AMission
{

const int MinSubMissionsforBlueSucces = 3;
const int MinSubMissionsforRedSucces = 3;
int BlueMissionSuccesses = 0;
int RedMissionSuccesses = 0;

int ScoreRed = 0;
int ScoreBlue = 0;


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

if (BlueMissionSuccesses < MinSubMissionsforBlueSucces && RedMissionSuccesses < MinSubMissionsforRedSucces)
{
if ("RedPartWin".Equals(shortName))
{
RedMissionSuccesses++;
ScoreRed += 10;
}

if ("BluePartWin".Equals(shortName))
{
BlueMissionSuccesses++;
ScoreBlue += 10;
}
}
else if (BlueMissionSuccesses >= MinSubMissionsforBlueSucces)
{
GamePlay.gpLogServer(null, "Blue already win this Battle", null);
}
else if (RedMissionSuccesses >= MinSubMissionsforRedSucces)
{
GamePlay.gpLogServer(null, "Red already win this Battle", null);
}
}



public override void OnTickGame()
{
base.OnTickGame();


if (Time.tickCounter() % 18000 == 17990) //check every 10 mins
{
if (BlueMissionSuccesses >= MinSubMissionsforBlueSucces || RedMissionSuccesses >= MinSubMissionsforRedSucces)
{

GamePlay.gpLogServer(null, "Team scores - RAF {0}: LW {1}", new object[] { ScoreRed, ScoreBlue });
GamePlay.gpLogServer(null, "Team Objectives Completed - RAF {0} of {1}: LW {2} of {3}", new object[] { RedMissionSuccesses, MinSubMissionsforRedSucces, BlueMissionSuccesses, MinSubMissionsforBlueSucces });
Timeout(10, () =>
{
if (BlueMissionSuccesses >= MinSubMissionsforBlueSucces)
GamePlay.gpHUDLogCenter("Blue Objective 11 Completed!!!");
else if (RedMissionSuccesses >= MinSubMissionsforRedSucces)
GamePlay.gpHUDLogCenter("Red Objective 11 Completed!!!");
});

BlueMissionSuccesses = 0;
RedMissionSuccesses = 0;
}
}
}
}

hc_wolf
03-27-2012, 10:33 AM
hummm i like it. I will have a look later and see if I can use it that way.

looks cleaner, but I have many triggers and see if it will work.

Thanks