PDA

View Full Version : [WIP] MissionTools dll


adonys
08-01-2011, 02:26 PM
I'm working on a .dll which should help all the FMB users out-there. This should shorten the mission's code, and keep the mission structure clearer, helping non C sharp mission designers do what they are doing the best :)

Here's the atm structure of the class

public class MissionTools {
public void MissionToolsInit(IGamePlay gamePlay, ITime time)

public bool PlayerIsAlive()
public List<Player> PlayerArmyList(int army)
public void PlayerPlace(int missionNumber, string groupName)

public AiActor ActorNameToActor(String actorName)
public AiAircraft ActorNameToAircraft (String actorName)

public bool AircraftIsAlive(AiAircraft aircraft)
public bool AircraftHitByAircraft(AiAircraft aircraft, List<DamagerScore> damages)
public bool AircraftHitBySAircraft(AiAircraft aircraft, List<DamagerScore> damages, AiAircraft sAircraft)
public bool AircraftHitByPlayer(AiAircraft aircraft, List<DamagerScore> damages)
// check if AiActor/aircraft was downed by aircraft/ship
// return highest aircraft/ship scorer on an AiActor/aircraft
public bool AircraftInGroup(AiAircraft aircraft, String airGroup)
public bool AircraftInGroup(String shortName, String airGroup)

public List<AiActor> GroupActorList(String groupName)
public void GroupRemoveActors(String groupName, double minDistance)

public double ActorToActorDistance(AiActor actor1, AiActor actor2)
public double AircraftToAicraftDistance(AiAircraft aircraft1, AiAircraft aircraft2)

public class Radar
public Radar RadarInit(AiActor radarActor, String radarName, int radarArmy, double radarRadius, int radarTimer)
public bool RadarIsAlive(AiActor actor, Radar radar)
public void RadarSweep(Radar radar)
private void RadarLockTargets(Radar radar)

public class BogieDetector
public BogieDetector BogieDetectorInit(AiActor detectorActor, String detectorName, int detectorArmy, int detectorTimer, int detectorSkill)
public bool BogieDetectorIsAlive(AiActor actor, BogieDetector detector)
public void BogieDetectorSweep(BogieDetector detector)
private void AircraftSpotBogies(BogieDetector detector)

public class AircraftParts
AircraftParts AicraftPartsInit()
public void AircraftDoRandomDamage(AiAircraft aircraft, int failuresNumber, AircraftParts ap)

public void HUDMessgeTo(string message)
public void HUDMessageToArmy(int army, string msg)
public void serverMessage(string msg)
// server message to army
}

public class PlayerInfo
public class Victory
public class MissionInfo
public class BriefingParser


Suggestions/requests?

stillborn
08-01-2011, 04:25 PM
looks nice :grin: , have you found a way to import/access this dll from mission script. i had trouble adding a namespace.

adonys
08-01-2011, 04:41 PM
there are two ways to do it atm:

1) this is the new one (haven't tested it yet)

//$reference parts/MissionTools/MissionTools.dll
using nsMissionTools;

mt = new MissionTools();
mt.MissionToolsInit(GamePlay, Time);

2) the old one (used by TEF in his server tool)

using nsMissionTools;

LoadDll();
mt = new MissionTools();
mt.MissionToolsInit(GamePlay, Time);

private void LoadDll() {
try {
//Load the new DLL from the specified path and set the current method to popCommand().
Assembly a = null;
a = Assembly.LoadFrom(Directory.GetCurrentDirectory() + @"\IL2ServerMasterLibrary.dll");
}
catch (Exception e) {
GamePlay.gpLogServer(new Player[] { GamePlay.gpPlayer() }, "ERR: Could not load MisionTools library!", null);
}
}

I also intend to add all the MP needed functions (to clean unused AIs, etc.)

Then I intend to release it for everyone, and use it to create a Dynamic Campaign Generator.

BTW, do you know any method to reference an AiActor from an AiAircraft (a simple one, not searching through all AiActors to find the one being that specific AiAircraft)? You can d it the other way around using (AiAircraft) AiActor or AiActor as AiAircraft, but how can I reverse this? I've asked naryv, but he hasn't responded yet..

stillborn
08-01-2011, 05:09 PM
Thanks, this would be useful.
BTW, do you know any method to reference an AiActor from an AiAircraft
AiAircraft is a class derived from AiActor, type casting works both ways, ive tested it like this
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
AiAircraft ac = actor as AiAircraft;
AiActor ak = ac as AiActor;
GamePlay.gpHUDLogCenter(ak.Name());
}

adonys
08-01-2011, 05:24 PM
hmm.. I didn't thought it might work both ways.. I'll need to do some testing then, thank you :)

41Sqn_Banks
08-01-2011, 09:44 PM
You can always cast from AiAircraft to AiActor but you can not always cast from AiActor to AiAircraft.

You can check if its possible to cast from AiActor to AiAircraft by this:


AiActor actor;
if( actor is AiAircraft )
{
AiAircraft aircraft = actor as AiAircraft;
...
}


If the "as" operator fails it returns null. This can be checked by

AiAircraft aircraft = actor as AiAircraft;
if(aircraft != null)
{
...
}


Of course its not necessary to check the success of the "as" operator if the "is" operator was successful.

adonys
08-01-2011, 10:18 PM
the problem was not with casting AiActor to AiAircraft, but viceversa.

TheEnlightenedFlorist
08-02-2011, 12:13 AM
I'm assuming there will be documentation? ;)

I'm assuming you're using Visual Studio? Unfortunately, Visual Studio doesn't include a nice html documentation generator. If you're not aware, there are several third party documentation generators. My favorite is Doxygen (http://www.stack.nl/~dimitri/doxygen/index.html). It uses Visual Studio's xml files to produce html files that are fairly easy to navigate, but most importantly, it's very easy to use.

adonys
08-05-2011, 05:00 PM
Of course there will be, I'll have to learn to use that Doxygen though :)

salmo
09-19-2011, 05:02 AM
Requesting...

public bool AircraftCrashlanded(Aircraft aircraft)
public bool AircraftCrashlandedAtFriendlyField(Aircraft aircraft)