PDA

View Full Version : Reddog's useful Scripts



SoW Reddog
Feb-10-2014, 10:05
Removed.

SoW Reddog
Feb-10-2014, 10:11
Removed

Mattias
Feb-10-2014, 10:30
Thank you Reddog -awesome! :clap::nw::clap::nw::clap::nw:

SoW Reddog
Feb-10-2014, 10:36
Removed

No.401_Wolverine
Feb-10-2014, 11:28
410!?

No.401 is the squadron, my good sir!

(Seriously though, good of you to post these up)

SoW Reddog
Feb-10-2014, 11:52
Ooops.

There'll be more to come, just need to untangle some mission specific stuff into more generic.

ATAG_Bliss
Feb-10-2014, 12:07
Great thread Reddog! :salute:

No601_Swallow
Feb-10-2014, 15:11
Simply the best <does demented Tina Turner dance, etc>.

It'll take me weeks to get to grips with this! Wonderful! :D

Edit: Bugger that. This is major! Serious thanks are in order!

SoW Reddog
Feb-11-2014, 11:28
Removed

fruitbat
Feb-11-2014, 19:08
Really cool thread, thank you very much.

SoW Reddog
Feb-12-2014, 10:19
Removed

Nephilim
Feb-18-2014, 17:02
Great stuff Mate, very useful...

"wall of death" script is missing:


bool PenaliseRedOverTheLine = true;

and also


public void CheckRedLineInfingements()
{
//////////////Comment this out as we don`t have Your Debug mode
//if (Debug)
//{
// GamePlay.gpLogServer(null, "Checking for RedLine Infingements", null);
//}


if (GamePlay.gpAirGroups(1) != null)
{
foreach (AiAirGroup ag in GamePlay.gpAirGroups(1)) // only red airgroups
{
foreach (AiAircraft a in ag.GetItems()) // each aircraft in each airgroup
{
if (!isAiControlledPlane(a)) // human planes only
{
Player p = a.Player(0); // the human pilot
if (p != null)
{
if (Players.ContainsKey(p))
{ // player has recieved a warning already
TimeSpan ts = DateTime.Now - Players[p]; // how long since the warning was given?
if (GamePlay.gpFrontArmy(a.Pos().x, a.Pos().y) != a.Army() && ts.TotalSeconds > WarningTimeLimit)
{ // player in enemy territory, has recieved warning & warning time limit expires
destroyPlayerPlane(a);
damagePlayerGroup(a);
}

else if (GamePlay.gpFrontArmy(a.Pos().x, a.Pos().y) != a.Army() && ts.TotalSeconds < WarningTimeLimit)
{ // player in enemy territory, has recieved warning but time not expired for getting back to safe area
// presumably, do nothing ...
}

else if (GamePlay.gpFrontArmy(a.Pos().x, a.Pos().y) == a.Army())
{ // player has recieved warning but is now back in safe area
Players.Remove(p);
}
}
else
{ // player has not recieved a warning
if (GamePlay.gpFrontArmy(a.Pos().x, a.Pos().y) != a.Army())
{ // player is in enemy territory
Players.Add(p, DateTime.Now); // remember player warned & when they were warned
GamePlay.gpHUDLogCenter(new Player[] { p }, "You have crossed the front line. You have 1 minute to return otherwise your plane will fall apart!");
}
}
}
}
}
}
}
}

SoW Reddog
Feb-18-2014, 17:25
Apologies, I'd assumed that people would start at the top. The debug and penalise variables are declared in the "global" portion of the first post. Would probably have been best to make reference to that in each post.

Compared to the stuff you showed me this is child's play.

ATAG_Lolsav
Feb-18-2014, 17:28
A quick thinking lead me to wonder: "This script could easily be transformed into a stop team killing one". The parameters would require input from community but deleting a offending plane could be a fast way to prevent that.

SoW Reddog
Feb-18-2014, 17:37
Removed

ATAG_Lolsav
Feb-18-2014, 17:40
Err.. its not the target killing. Its the friendly fire consistent team killing one ;)

SoW Reddog
Feb-18-2014, 17:55
Removed

ATAG_Lolsav
Feb-18-2014, 18:06
Hmmm im talking about a plane shooting a friendly plane.

SoW Reddog
Feb-19-2014, 03:49
Removed

ATAG_Lolsav
Feb-19-2014, 06:55
Where i see they are alike:

1. There is a warning

2 . There is a transgression

3. The offender plane is deleted

4. It can store the name to check for repeating offending behaviour - Kick or to dammage offender plane (criple) once spawn

SoW Reddog
Feb-28-2014, 04:58
Removed

No601_Swallow
Feb-28-2014, 07:30
This has the potential to be a real game changer. If every airfield layout has its own .mis file in the airports folder - which itself is a permanent fixture on the server, so long as they are sensibly named, the mission builder only has to edit this script to add spawnpoints, airfields (and potentially, I suppose) much else in future - spline roads, convoys, perhaps, moving columns... all by simply amending the script!

Genius!

It'd take a bit of work to set up though...:thumbsup:

Edit: :doh:Hmm. Scratch that. I may have misunderstood. You'd probably swap airport .mis files into and out of the folder, rather than tamper with the script. And Steam won't let me into multiplayer at the moment, so I can't muck about with it! Grr.

Edit again! Or... I wonder if it would be possible for the script to be amended to include an easily editable list of .mis files it would check... in which case we could go back to idea number one! Oh I wish my son was old enough to send to Scripting School!

SoW Reddog
Feb-28-2014, 08:10
Removed

Salmo
Mar-02-2014, 04:54
Wrote this to illustrate a concept for the Tangmere Pilots who are hosting lots of spawn configurations here (http://www.tangmerepilots.co.uk/NewForum/viewforum.php?f=65) but figured I should post it here too.

Basic idea is that rather than having to integrate the special spawn layouts and scenery templates into your mission .mis file, with the attendant risk of cocking up renumbering Airdromes etc simply create and save a sub mission into a subfolder (called Airfields) within the mission directory, containing all the spawns for a particular airfield. For example, I quickly created a file for each of the templates Tangmere Pilots have released thus far.

The code below then represents the entire .cs file to prove the concept. This loops through all the files present in that directory and loads all spawn points as the battle is created. You could use a similar idea to load target templates into maps, or anything where large numbers of objects are likely to remain static. I'll probably use them to create RDF sites going forward.


NOTE: Obviously you'll need to change the path variables to reflect your own mission name and location, as well as the temp variable in ReadAirfieldSpawns.


using System.Text;
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Diagnostics;
using System.IO;
using part;
using System.Runtime.InteropServices;
using System.Globalization;
//$reference parts/core/gamePlay.dll



public class Mission : AMission
{
//Variable Declarations
#region Global Setting on/off Switches
public bool Debug = true;//Flag for Debug output on/off
#endregion
#region Path Variables
private static string userdocpath = Environment.GetFolderPath(Environment.SpecialFolde r.MyDocuments);
private static string CLODO_FILE_PATH = userdocpath + @"\1C SoftClub\il-2 sturmovik cliffs of dover - mod\missions\AirfieldSpawnTest\"; // THIS IS THE PATH OF YOUR Mission folder
private static string FILE_PATH = @"AirfieldSpawnTest.mis"; // THIS MUST INDICATE THE MISSION FILE NAME THAT YOU ARE USING THIS SCRIPT IN AND ITS LOCATION FROM THE FOLDER ABOVE
private static string MISSION_FILE = CLODO_FILE_PATH + FILE_PATH;
#endregion
public override void OnBattleStarted()
{
base.OnBattleStarted();
ReadAirfieldSpawns();
}
public void ReadAirfieldSpawns()
{
string[] array = Directory.GetFiles(CLODO_FILE_PATH + @"Airfields\");
foreach (string s in array)
{
string temp = @"missions\AirfieldSpawnTest\Airfields\" + Path.GetFileName(s);
GamePlay.gpPostMissionLoad(temp);
if (Debug)
{
GamePlay.gpLogServer(null, temp + " file Loaded", null);
}
}

}

}

Oooh! I like this concept very much, you are a clever fellow :thumbsup:

Statics spawn from sub-missions OK, but do you have a problem with buildings not spawning from sub-missions?

SoW Reddog
Mar-03-2014, 02:44
Removed

No601_Swallow
May-03-2014, 04:36
Bump!

AKA_Recon
May-14-2014, 09:26
your code on knocking out airfields is very good - I was wondering how this worked - fantastic work.

much appreciated for you to take the time to share this!

You wouldn't happen to have some simple mission setups to share ?

Side question : do you have a certain testing procedure - ie. do you run VS in debugger - ie. testing a trigger ?

Thanks again

SoW Reddog
May-15-2014, 04:53
Sorry Recon, I don't have any simple missions to share. I do all my development in a single mission these days pretty much. What exactly were you after?

I'm not sure I understand your question about debugger. I use the compile within the FMB to eliminate script errors, and have my own debug output system that tracks actual logic flow and values changing.

72sq_Savinio
Jul-05-2014, 12:06
AirfieldTargets.Remove(ap);
AirfieldTargets.Add(ap, Tuple<bool, string, double, double>(true, Mission, WeightToKnockOut, WeightTaken));




Hi Reddog, first of all thank you very much for all your post in FMB section of this forum.
I try to use "Adding and Removing Spawn Bases (2)" in my mission .cs file. But c# compiler, in the quote, give me that error ///// System.Tuple<bool, string, double, double> is a 'type' but is used like a 'variable' ////////.
So i'm member of the second, also third, division FMBuilder champioship :salute: and i don't understand how can i correct this error that could be accessible for premierleague FMbuilder. Thanks again.
72sq_Savinio