Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

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

Reply
 
Thread Tools Display Modes
  #151  
Old 05-23-2011, 07:09 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Flashman,

OnTickGame() is called 30 times in second and every second, so your script 30 times in second schedules a mission loading, and repeats that endlessly. You are abusing your computer

Put this into Init(), not in OnTickGame().

Last edited by ZaltysZ; 05-23-2011 at 07:12 PM.
Reply With Quote
  #152  
Old 05-23-2011, 08:03 PM
Flashman Flashman is offline
Approved Member
 
Join Date: May 2010
Posts: 109
Default

Quote:
Originally Posted by ZaltysZ View Post
Flashman,

OnTickGame() is called 30 times in second and every second, so your script 30 times in second schedules a mission loading, and repeats that endlessly. You are abusing your computer

Put this into Init(), not in OnTickGame().

Hi Zaltys,

Thanks for your help, however please excuse my ignorance. I have tried putting Init() in carious places but I can't work it out. ANy chance you can edit my previous file and put it in the correct place so I can see how it should work? I really have no idea what im doing......

Thanks
Reply With Quote
  #153  
Old 05-23-2011, 08:14 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

PHP Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class 
Mission AMission
{
    public 
override void Init(maddox.game.ABattle battleint missionNumber)
    {
        
base.Init(battle,missionNumber);
           
Timeout(60, () =>
    
            {    
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Channelv1/BM2/sb1d.mis");    
                
GamePlay.gpHUDLogCenter("Intel: Stuka raid 1XXX inbound at Angels 13, heading W"); 
            });

        }

If you forget base.Init(battle,missionNumber); in Init(), script won't work.
Reply With Quote
  #154  
Old 05-23-2011, 08:22 PM
Flashman Flashman is offline
Approved Member
 
Join Date: May 2010
Posts: 109
Default

Quote:
Originally Posted by ZaltysZ View Post
PHP Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class 
Mission AMission
{
    public 
override void Init(maddox.game.ABattle battleint missionNumber)
    {
        
base.Init(battle,missionNumber);
           
Timeout(60, () =>
    
            {    
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Channelv1/BM2/sb1d.mis");    
                
GamePlay.gpHUDLogCenter("Intel: Stuka raid 1XXX inbound at Angels 13, heading W"); 
            });

        }

If you forget base.Init(battle,missionNumber); in Init(), script won't work.
Thanks, that now works as I had hoped!

I had worked out I was missing the (battle, mission....) part but it still didn't work. it was the base.init part that made it function correctly, and I wouldn't have a clue about that.

Cheers!
Reply With Quote
  #155  
Old 05-24-2011, 07:20 AM
klem's Avatar
klem klem is offline
Approved Member
 
Join Date: Nov 2007
Posts: 1,653
Default

Quote:
Originally Posted by Ataros View Post
This sample script made for fun disables player controls. Maybe someone can use it to disable AI controls for say 10 minutes before destroying AI

Code:
 using System;
 using maddox.game;
 using maddox.game.world;

     public class Mission: maddox.game.AMission
     {
  	 / / Override the method that is invoked when some of the planes will take off ...
	 public override void OnAircraftTookOff (int missionNumber, string shortName, AiAircraft aircraft)
         {
             base.OnAircraftTookOff (missionNumber, shortName, aircraft); / / call the base method (you never know ...)
             if (GamePlay.gpPlayer ()! = null) / / check if we have a player.
             {
                 if (GamePlay.gpPlayer (). Place ()! = null) / / check that the player is sitting somewhere and not hanging out on the rag.
                 {
                     if (aircraft.Name (). Equals (GamePlay.gpPlayer (). Place (). Name ())) / / if the plane took off - a player, then ...
                     {
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); / / ... disables  elevators ...
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); / / ...  aileron ...
                         aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); / / ...  rudder.
						 / / Have a nice flight!
                     }
                 }
             }
         }      
     }
More scripts here http://translate.google.com/translat...hp%3Ft%3D68369
Can anyone see what's wrong with the following? I get the first test message at about +45 seconds while still in the hangar (engine on or engine off), repeated every 20 seconds (which is strange) until about mission start +3mins but I never get the second test message or the messages that follow in the "if" statement:


//SEND MESSAGE TO PLAYER WHEN THEY HAVE TAKEN OFF

public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff(missionNumber, shortName, aircraft);

GamePlay.gpHUDLogCenter("Takeoff messages start."); //Test/debug Message

if (aircraft.Name() == GamePlay.gpPlayer().Place().Name()) // if the plane took off - a player, then ...
{

GamePlay.gpHUDLogCenter("Switch section reached"); //Test/debug Message

switch (aircraft.Army())
{
case 1:
if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber)) // if Bomber or Divebomber
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised! Attack briefed targets!"); }
else
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Organise Escorts and protect Convoy moving from Beachy Head to the Thames Estuary!"); }
break;
case 2:
if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber)) // if Bomber or Divebomber
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised and attack briefed Targets!"); }
else
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Remember, Get Organised and protect our bombers by Escort or Frei Jagd!"); }
break;
}

}

} //end public override void OnAircraftTookOff
__________________
klem
56 Squadron RAF "Firebirds"
http://firebirds.2ndtaf.org.uk/



ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU
Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders
Reply With Quote
  #156  
Old 05-24-2011, 11:08 AM
Iku_es Iku_es is offline
Approved Member
 
Join Date: May 2011
Location: Bilbao, Spain
Posts: 30
Default

Hi,

I have never tried scripting for Clod, but as a C# programer, I'm going to make an educated guess:

Try changing this line:

if (aircraft.Name() == GamePlay.gpPlayer().Place().Name() )

for this one:

if ( aircraft.Name().Equals(GamePlay.gpPlayer().Place().Name()) )

I'm not sure of this because I don't know the types of the objects involved in the comparison (strings?), but try it anyway.

(Check this for more info about why: C# Value Type vs Reference Type)

Also you should check that aircraft is not null, and that GamePlay.gpPlayer().Place() is not null, for security reasons in order to avoid NullReference exceptions.

Last edited by Iku_es; 05-24-2011 at 01:18 PM.
Reply With Quote
  #157  
Old 05-24-2011, 01:18 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

klem,

OnAircraftTookOff(() does not currently work for planes spawned at BirthPlaces. It should work for FMB planes with waypoints. I guess, you get first message showed because you have AI taking off.
Reply With Quote
  #158  
Old 05-24-2011, 01:26 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

Instead of;

Code:
if (aircraft.Name() == GamePlay.gpPlayer().Place().Name())
try

Code:
if (aircraft == GamePlay.gpPlayer().Place())
By the way, GamePlay.gpPlayer() returns player of offline mission. This won't return a client player in MP, so if you are doing MP mission, this won't work.
Reply With Quote
  #159  
Old 05-24-2011, 02:45 PM
klem's Avatar
klem klem is offline
Approved Member
 
Join Date: Nov 2007
Posts: 1,653
Default

Quote:
Originally Posted by ZaltysZ View Post
Instead of;

Code:
if (aircraft.Name() == GamePlay.gpPlayer().Place().Name())
try

Code:
if (aircraft == GamePlay.gpPlayer().Place())
By the way, GamePlay.gpPlayer() returns player of offline mission. This won't return a client player in MP, so if you are doing MP mission, this won't work.
Thanks guys.

It was for MP and for a BirthPlace so a double fail

btw I had it report aircraft.Name() and GamePlay.gpPlayer().Place().Name() and they were the same string so 'If == ' should have worked ok.
__________________
klem
56 Squadron RAF "Firebirds"
http://firebirds.2ndtaf.org.uk/



ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU
Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders
Reply With Quote
  #160  
Old 05-24-2011, 02:56 PM
klem's Avatar
klem klem is offline
Approved Member
 
Join Date: Nov 2007
Posts: 1,653
Default

Quote:
Originally Posted by TheEnlightenedFlorist View Post
Hi klem, I think the best way to accomplish that would be to use a trigger, action, and a script..........................

The script will look like this:

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)
    {
        //call base classes OnTrigger method.
        base.OnTrigger(missionNumber, shortName, active);

        //if the trigger that was called is the trigger that we're looking for
        if (shortName.Equals("attackConvoyDelay") && active)
        {
            AiAction action = GamePlay.gpGetAction("attackConvoy"));
            if (action != null)
                 action.Do();

        }
}
So if you put this code into the mission's script file, it will trigger your action whenever your trigger... triggers.

Note that I've named the trigger "attackConvoyDelay" and the action "attackConvoy". You can change them to whatever you want, just make sure they are the same in both the mission and the script.

I hope this helps.
Thought I'd report back on this, I eventually got the following to work:

public override void OnTrigger(int missionNumber, string shortName, bool active)

{
//call base classes OnTrigger method.
base.OnTrigger(missionNumber, shortName, active);
GamePlay.gpHUDLogCenter("shortname = " + shortName);
//if the trigger that was called is the trigger that we're looking for
if (shortName.Equals("AttackConvoy2Delay1"))
{
AiAction action = GamePlay.gpGetAction("AttackConvoy2_1") ;
if (action != null)
{ action.Do(); }
}


}

The '&& active' didn't work because:
1. It seems it should be + not &&
2. You can see I tested for the shortname and of course ("AttackConvoy2Delay1" + active) isn't equal to "AttackConvoy2Delay1". I don't know what 'active' comes back as but it would make the strings unequal.

Also, I put { } around the if(action != null) output as { action.Do(); } although that may not havebeen necessary.

Anyway it works !

Thanks for the help TheEnlightenedFlorist.
__________________
klem
56 Squadron RAF "Firebirds"
http://firebirds.2ndtaf.org.uk/



ASUS Sabertooth X58 /i7 950 @ 4GHz / 6Gb DDR3 1600 CAS8 / EVGA GTX570 GPU 1.28Gb superclocked / Crucial 128Gb SSD SATA III 6Gb/s, 355Mb-215Mb Read-Write / 850W PSU
Windows 7 64 bit Home Premium / Samsung 22" 226BW @ 1680 x 1050 / TrackIR4 with TrackIR5 software / Saitek X52 Pro & Rudders
Reply With Quote
Reply


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 11:31 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.