1C Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official 1C Company forum > 1C Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2013, 09:12 PM
Hood Hood is offline
Senior Member
 
Join Date: Jan 2008
Posts: 318
Default Script needed

Hi all

I need a script for a small DF mission I have made. I have 4 triggers. There are 4 trigger names which are the same for trigger and action.

1. Ju87s spawn after 600 seconds

2. Blenheims spawn after 900 seconds

3. A Bf108 spawns after 1200 seconds

4. If the Bf108 is 50%+ destroyed some 109s spawn in.

The best I can do is the following but it won't work in mission:


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

public class Mission : AMission
{

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

if ("Blenheims".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Blenheims"); //same as YourTriggerName
GamePlay.gpLogServer(null, " RAF bomber group spawned ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}

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

if ("Ju87s".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Ju87s"); //same as YourTriggerName
GamePlay.gpLogServer(null, " German bomber group spawned ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}

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

if ("Bf108".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Bf108"); //same as YourTriggerName
GamePlay.gpLogServer(null, " German air group spawned ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}

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

if ("Bf109s".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Bf109s"); //same as YourTriggerName
GamePlay.gpLogServer(null, " Eeek - huns in the sun! ", new object[] { }); //Testmessage
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}



Any suggested changes?

Hood
Reply With Quote
  #2  
Old 08-10-2013, 03:45 AM
bolox bolox is offline
Approved Member
 
Join Date: May 2008
Posts: 351
Default

you only need one instance of the "public overide void on trigger" with all four triggers contained within it.

am doing this from a phone so can't paste an example for you.
should have computer/ internet access tomorrow if you haven't figured it out by then.
Reply With Quote
  #3  
Old 08-10-2013, 11:03 AM
Hood Hood is offline
Senior Member
 
Join Date: Jan 2008
Posts: 318
Default

Quote:
Originally Posted by bolox View Post
you only need one instance of the "public overide void on trigger" with all four triggers contained within it.

am doing this from a phone so can't paste an example for you.
should have computer/ internet access tomorrow if you haven't figured it out by then.
Hi bolox

I'll need an example - I have a HUGE blind spot when it comes to coding.

Thanks

Hood
Reply With Quote
  #4  
Old 08-10-2013, 01:03 PM
bolox bolox is offline
Approved Member
 
Join Date: May 2008
Posts: 351
Default

ok, new modem and I have internet

you need to have something like this example with 4 triggers in
Code:
  
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

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

          if ("41".Equals(shortName) && active) 
          { 
                AiAction action = GamePlay.gpGetAction("41");
                if (action != null)
                {
                     action.Do();
                }
                GamePlay.gpHUDLogCenter("41");      
                GamePlay.gpGetTrigger(shortName).Enable = false;            
          }
		  
		if ("46".Equals(shortName) && active) 
          { 
                AiAction action = GamePlay.gpGetAction("46");
                if (action != null)
                {
                     action.Do();
                }
                GamePlay.gpHUDLogCenter("46");      
                GamePlay.gpGetTrigger(shortName).Enable = false;   
    }
	if ("605".Equals(shortName) && active) 
          { 
                AiAction action = GamePlay.gpGetAction("605");
                if (action != null)
                {
                     action.Do();
                }
                GamePlay.gpHUDLogCenter("605");      
                GamePlay.gpGetTrigger(shortName).Enable = false;            
          }
	
		  
	
	if (GamePlay.gpGetTrigger("mis").Active) {
        end = true;
        //GamePlay.gpHUDLogCenter("!");
    }
}
}
basically rename this as your mission name and change the trigger names should get you going- you can then change the HudLog messages to server messages if you wish.

I don't think I've made any errors but I haven't tested this, just cut out a trigger section from one of my campaigns and plugged it into the structure you gave (Amission etc)

good luck
Reply With Quote
  #5  
Old 08-10-2013, 05:16 PM
Hood Hood is offline
Senior Member
 
Join Date: Jan 2008
Posts: 318
Default

Thanks. I think I need one extra section but will copy and paste.

Thanks again

Hood
Reply With Quote
  #6  
Old 08-10-2013, 06:09 PM
bolox bolox is offline
Approved Member
 
Join Date: May 2008
Posts: 351
Default

there are actually 4 triggers- just the last one
Code:
if (GamePlay.gpGetTrigger("mis").Active) {
        end = true;
        //GamePlay.gpHUDLogCenter("!");
    }
is a slightly different format- replace with earlier type.

You using notepad++/visual studio? - these will help with 'bracket pairing' and finding line numbers for any errors generated
Reply With Quote
  #7  
Old 08-10-2013, 07:04 PM
Hood Hood is offline
Senior Member
 
Join Date: Jan 2008
Posts: 318
Default

Um just notepad or word pad.

I think I can work out the brackets. Too busy toasting marshmallows right now though. Will try it tomorrow and will report back.

Hood
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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

Based on a design by: Miner Skinz.com

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