Official 1C Company forum

Official 1C Company forum (http://forum.1cpublishing.eu/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.1cpublishing.eu/forumdisplay.php?f=203)
-   -   Build/Play Messages using Scripting (http://forum.1cpublishing.eu/showthread.php?t=26245)

FG28_Kodiak 01-24-2012 07:16 PM

Have delete my post.

Riksen 11-02-2013 10:05 PM

How can I get this to work with the ontrigger feature? I want to set the message display only when the aircrafts enter the trigger zone and not by time ... Is it possible?

Riksen 11-03-2013 06:40 AM

Never mind I got it ....
 
Wow ... I made it work with triggers as well. Sorry if I sound overly exited ... It's just all new to me. Well thxs for the tutorial guys.

Im posting the code here with both examples in one file, that is, messages on the timer and messages with a pass through trigger.

Code:

using System;
using maddox.game;
using maddox.game.world;


public class Mission : AMission {

    AiActor a1;
    AiAircraft airc1;

    public override void OnBattleStarted() {
        base.OnBattleStarted();
        a1 = GamePlay.gpActorByName("0:BoB_LW_JG54_Stab.000");


        if (a1 == null) {
            GamePlay.gpLogServer(null, "SCRIPT ERROR: Aircraft not found\n", new object[] { });
        }

        airc1 = (AiAircraft)a1;
    }


    public override void OnTickGame() {
        if (Time.tickCounter() == 300) {
            double initTime = 0.0;
            airc1.SayToGroup(airc1.AirGroup(), "1_mile");
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "1_mile");
                });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Cargo_Ships");
                });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Destroy_targets_left_to_right");
                });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Attack");
                });
        }       
    }


    public override void OnTrigger(int missionNumber, string shortName, bool active) {
        if ("trigger01".Equals(shortName) && active) {
            double initTime = 0.0;
                            Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "K");
                            });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Loitering_here");   
                });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Pay_attention");     
                });
                Timeout(initTime += 5.0, () => {
                    airc1.SayToGroup(airc1.AirGroup(), "Please_climb_now");       
                });                     
        }
    }
}



All times are GMT. The time now is 10:46 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2007 1C Company. All rights reserved.