View Single Post
  #76  
Old 04-30-2011, 01:09 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by Flashman View Post
Hi Ataros,

Hopefully I will be a little more clear this time!

I used the in-game script system using a Trigger to cause an Action to happen. Eg in my missions if a plane I select is shot down, it triggers the spawn of another plane.

EDIT>Script

Trigger: Walrus 1= Target Group destroyed (Walrus flying boat selected)
Action: Walrus 1= Air spawn group (second walrus selected)

This system works in single player, so that when the first walrus is shot down a second spawns at a preselected place. However, when I include the scripts you guys have been developing to despawn empty aircraft (for use online) the ingame script above does not work in either single or multiplayer.

Any ideas what i am doing wrong?
Checked ingame trigger system. Did not work with external scrips but it is by itself just fantastic! I think it is possible to achieve what I tried to do loading sub-missions into a mission with this trigger system only. I'll switch to it for a while from scripting as I do not know C#. Very helpful thread on this http://forum.1cpublishing.eu/showthr...builder&page=2

However we should try:

1) make a mission with internal triggers without script
2) make a mission with script that loads the first mission in.
3) load more missions when needed.
I will not have time to try this for a couple of days however ((

Alternatively you can program all the triggers in a script by hand. Check links in the 1st message of this thread for examples.

e.g.
Code:
  / / $ Reference Campaign.dll
 / / - $ Debug
 using System;
 using maddox.game;
 using maddox.game.world;

 public class Mission: maddox.game.campaign.Mission {

	 public override void OnTrigger (int missionNumber, string shortName, bool active)
         {
             if ("trigger". Equals (shortName) & & active)
            {
                 GamePlay.gpHUDLogCenter ("Triggers trigger");
             }   
         }
 
 }
Code:
  using System;
 using maddox.game;
 using maddox.game.world;


 class Mission: maddox.game.AMission
 {
	 public override void OnActorDead (int missionNumber, string shortName, AiActor actor, System.Collections.Generic.List <DamagerScore> damages)
	 {
		 base.OnActorDead (missionNumber, shortName, actor, damages);
		 AiAction action = GamePlay.gpGetAction ("TestAction");
		 if (action! = null)
		 {
			 action.Do ();
		 }
	 }
 }
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

    public class Mission : maddox.game.AMission
    {
        private List<AiAction> actions = new List<AiAction>();
        private int round = 1;
        private bool completed = false;
        
        public override void OnBattleStarted()
        {
            AiAction action = GamePlay.gpGetAction("startGroup2");
            if (action != null) actions.Add(action);
            action = GamePlay.gpGetAction("startGroup3");
            if (action != null) actions.Add(action);
            GamePlay.gpHUDLogCenter(String.Format("Раунд {0}", round));
        }

        public override void OnActorDead(int missionNumber, string shortName, AiActor actor, System.Collections.Generic.List<DamagerScore> damages)
        {
            base.OnActorDead(missionNumber, shortName, actor, damages);
            if (!(actor is AiAircraft))
                return; // Не самолет

            int army = (actor as AiAircraft).Group().Army();
            if (army == 1)
            {
                if (!completed)
                {
                    bool fail = (actor as AiAircraft).AirGroup().DiedAircrafts >= (actor as AiAircraft).AirGroup().InitNOfAirc;
                    if (fail)
                    {
                        GamePlay.gpHUDLogCenter("Миссия провалена.");
                    }
                }
            }
            else
            {
                bool next = (actor as AiAircraft).AirGroup().DiedAircrafts >= (actor as AiAircraft).AirGroup().InitNOfAirc;
                if (next)
                {
                    if (round == 3)
                    {
                        completed = true;
                        GamePlay.gpHUDLogCenter("Поздравляем, миссия пройдена!");
                    }
                    else
                    {
                        round++;
                        startNewRound();
                    }
                }
            }
        }

        private void startNewRound()
        {
            GamePlay.gpHUDLogCenter(String.Format("Раунд {0}", round));
            if (actions.Count > 0)
            {
                actions[0].Do();
                actions.RemoveAt(0);
            }
        }
    }

http://translate.google.com/translat...hp%3Ft%3D68369

Quote:
Originally Posted by mcler002 View Post
Ive tested and tested... its not working :S

Help !

Would you tell us what exactly you are trying to do and what does not work. Run my script it loads missions on timing more or less. Does not always destroy planes on the server however.

Last edited by Ataros; 04-30-2011 at 01:23 AM.
Reply With Quote