View Single Post
  #169  
Old 06-21-2011, 12:48 PM
SNAFU SNAFU is offline
Approved Member
 
Join Date: Feb 2011
Posts: 324
Default

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 02:45 PM.
Reply With Quote