PDA

View Full Version : Script needed



69th_Spiritus_Mortem
Jun-15-2014, 22:23
I am hoping for some help from you scripting Einsteins out there... you know who you are!

Anyways, Wolverine and I have been discussing the idea and think it is possible but I have struck out, mainly due to my lack of knowledge in hard coding.

So, I am making another mission and would like to add a SAR objective for a side. A high ranking officer and highly classified documents went down behind enemy lines. One must fly their aircraft, land in the field and stop for a certain amount of time before the pass through trigger notifies them that the officer and documents are on board, then has to take off, return to a specific base, land and taxi to another pass through trigger before the objective is met. At anytime they fail or crash or get shot down, then that objective returns and is open for anyone to try again.

Wolverine had some pointers, like having a timer added to the pass through triggers which would prevent someone from just flying around in circles. We could make the pass through 2m so it would be impossible to trigger it if someone had to stay inside it for say a minute.

Anyways, I really hope we can get some help with this, I think it could add a lot to missions for all the servers out there. It would be epic to have to land in a field, taxi up to a downed aircraft, wait, fly back and land safely then have to taxi into a hanger before the objective is met.

Also, would it be possible to dictate what aircraft does this? I would like to see bombers do this since A) they have the room to pick people up and B) give them more things to do.

Hope you guys can and are willing to help!

Cheers

Here is a screen grab of my mission, hoping to be able to make this work!!!!

AKA_Recon
Jun-16-2014, 08:19
Are there any events that fire when you land your aircraft - and does it give info on the aircraft that landed (coordinates, who, etc... ?)

Not sure about the API

SoW Reddog
Jun-16-2014, 10:15
Its certainly possible.

Why don't you have a bash at it yourself and learn in the process, then I'm sure someone will help get it working.

69th_Spiritus_Mortem
Jun-16-2014, 11:41
Are there any events that fire when you land your aircraft - and does it give info on the aircraft that landed (coordinates, who, etc... ?)

Not sure about the API

Right now I have it so when you land and taxi to the downed aircraft you get a notification that the documents and person is on board. I am adding a 1 min timer to that pass-through trigger which seems to work.

69th_Spiritus_Mortem
Jun-16-2014, 11:44
Its certainly possible.

Why don't you have a bash at it yourself and learn in the process, then I'm sure someone will help get it working.

Just the person I was hoping to entice! If you say its possible then I will keep plugging away. I just got to the point where if it wasn't possible I needed to know so I could save my brain but now that I know it can work I will keep at it.

I'll post what I have once I get some more of it working, I think what I am struggling the most in is linking the two pass-through triggers together as a single objective but I will keep at it.

Thanks guys!

bolox
Jun-17-2014, 14:55
Don't know if this will help as it is from an SP campaign, but it does use triggers and player landing at a defined base and combines results from 2 triggers.


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



if (GamePlay.gpGetTrigger("land").Active) {
lnd = ++lnd; //increement lnd counter

//GamePlay.gpHUDLogCenter("land:"+lnd);
}
if (GamePlay.gpGetTrigger("mis").Active) {
end = true;
//GamePlay.gpHUDLogCenter("!"); // define reached mission objective
}
}
public override bool IsMissionListener(int missionNumber) {
return true;
}

private void checkLanded(AiAircraft aircraft) {
if (GamePlay.gpPlayer().Place() != aircraft)
return;
if ((end = true) && (lnd > 1)) // check landed, flown out of france and returned, reached mission objective
{

Campaign.battleSuccess = true;

GamePlay.gpHUDLogCenter("GUT GEMACHT!");
}
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) {
checkLanded(aircraft);
}

public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) {
checkLanded(aircraft);
}

One thing I find tho with the 'onAircraftLanded' function is that it is an event that is triggered when the AC STOPS moving, not when it touches down. In the example above player has to return to base so I used an increment counter to avoid it being triggered on take off.
The commented out HUDLOG lines are for testing purposes.
You probably would want to remove the 'OnAircraftCrashLanded' section as this causes a crash landed plane to register as landed- which is not appropriate for your mission.

Hope this is of some use.

69th_Spiritus_Mortem
Jun-17-2014, 16:35
Bolox, thank you very much for this! This will help tremendously, I seem to be able to learn quicker and understand the coding more when I have something to look off of that is similar. I can't seem to make up my own without piecing it together from multiple other scripts.

Thanks again for this! I will continue to mess around and see what I can come up with and post it here for help/critique/improvement/public-use.

:salute:

SoW Reddog
Jun-17-2014, 17:44
I seem to be able to learn quicker and understand the coding more when I have something to look off of that is similar. I can't seem to make up my own without piecing it together from multiple other scripts.

How'd you think the rest of us are learning :)

69th_Spiritus_Mortem
Jun-17-2014, 23:26
Bolox,

Are these libraries enough for the code you gave me?

using System.Text;
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading;

When I compile I get a few "name doesnt exist" errors, for end, ind, and campaign.

bolox
Jun-18-2014, 03:59
end and ind are defined earlier in script


bool end = false;
int lnd = 0;

campaign is a specific call for SP campaigns- they need a line

public class Mission : maddox.game.campaign.Mission
BUT THIS IS FOR SP CAMPAIGNS ONLY
For MP (and single missions) use the 'normal'

public class Mission : AMission
- campaign has a 'special' version of dll that includes the 'campaignbattle success' param and needs a slight modification to header. But for your use this is not needed- I would just remove/comment out this line.
The 'using' section you posted looks ok- I don't know what methods you are calling in other parts of your script.
Basically if you use a method that comes from a class you must specify you will be using it in the header.
It looks like you have more than enough in this section.

FOR REFERENCE- here is the header for the campaign script I showed a bit of

//$reference Campaign.dll
//-$debug
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
using maddox.GP;

public class Mission : maddox.game.campaign.Mission
{

YOUR CODE HERE

}

for SP missions/MP this is the normal format


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

public class Mission : AMission
{
// your code here
}

Another of CoD's little quirks:devilish:

69th_Spiritus_Mortem
Jun-18-2014, 11:09
Great info, thank you for those clarifications, I always hesitate deleting parts of the code thinking somehow CloD is using it.

Cheers!

69th_Spiritus_Mortem
Jun-22-2014, 14:38
Help on this error?

c:\Users\Chris\Documents\1C SoftClub\il-2 sturmovik cliffs of dover - MOD\missions\Single\Testscripts.cs(80,1): error CS1022: Type or namespace definition, or end-of-file expected


Here is the code:

using System.Text;
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading;

public class Mission : AMission
{
bool end = false;
int lnd = 0;
public override void OnTrigger(int missionNumber, string shortName, bool active)

{
base.OnTrigger(missionNumber, shortName, active);

base.OnTrigger(missionNumber, shortName, active);

if ("SAR".Equals(shortName))
{
AiAction Action = GamePlay.gpGetAction("SAR"); // if your action has an other Name than your trigger change GamePlay.gpGetAction(shortName) into GamePlay.gpGetAction("ActionName")
GamePlay.gpHUDLogCenter("Classified Documents and General Potter on Board!");
if (Action != null)
Action.Do();

GamePlay.gpGetTrigger(shortName).Enable = false; // if trigger is TPassThru to avoid multiple activation

return; // leave method to avoid second call of the Action
}

if ("SAR2".Equals(shortName))
{
AiAction Action = GamePlay.gpGetAction("SAR2"); // if your action has an other Name than your trigger change GamePlay.gpGetAction(shortName) into GamePlay.gpGetAction("ActionName
GamePlay.gpHUDLogCenter("Classified Documents and General Potter Returned to Base! ");
if (Action != null)
Action.Do();

GamePlay.gpGetTrigger(shortName).Enable = false; // if trigger is TPassThru to avoid multiple activation

return; // leave method to avoid second call of the Action
}

if (GamePlay.gpGetTrigger("SAR2").Active)
{
lnd = ++lnd; //increement lnd counter

//GamePlay.gpHUDLogCenter("SAR2:"+lnd);
}
if (GamePlay.gpGetTrigger("SAR").Active)
{
end = true;
//GamePlay.gpHUDLogCenter("SAR"); // define reached mission objective
}
}
public override bool IsMissionListener(int missionNumber)
{
return true;
}

private void checkLanded(AiAircraft aircraft)
{
if (GamePlay.gpPlayer().Place() != aircraft)
return;
if ((end = true) && (lnd > 1)) // check landed, flown out of france and returned, reached mission objective
{

GamePlay.gpHUDLogCenter("General Potter and the Classified Documents have been Safely Recovered!");
}
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
checkLanded(aircraft);
}
}
}

bolox
Jun-23-2014, 01:55
A very quick look would suggest you need to remove the final bracket (on line 80)- the first bracket in the script pairs with the one on line 79, so the line 80 one is surplus and would give the error shown.

69th_Spiritus_Mortem
Jun-23-2014, 10:26
I tried removing it since I finally learned how to semi-read those errors after hitting compile. That error does go away but about 5 others show up.

That is what confused me, by putting that bracket on line 80 it seemed to clear up those other errors but in return gave me the above mentioned error.

AKA_Recon
Jun-23-2014, 18:14
If you want to sent to me I can take a look

No601_Swallow
Jun-24-2014, 03:16
If you want to sent to me I can take a look

Yeah, but please post the result up here, for those of us with our noses pressed up against the glass! :thumbsup:

AKA_Recon
Jun-24-2014, 19:03
builds ok for me (in Visual Studio & if I copy that script into FMB) after removing last bracket

69th_Spiritus_Mortem
Jun-30-2014, 23:56
Interesting, I will take a look later, just got back from camping. I really hope we can get this script working!

Salmo
Jul-01-2014, 01:05
public class Mission : AMission
{
bool end = false;
int lnd = 0;

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

if ("SAR".Equals(shortName))
{
AiAction Action = GamePlay.gpGetAction("SAR"); // if your action has an other Name than your trigger change GamePlay.gpGetAction(shortName) into GamePlay.gpGetAction("ActionName")
GamePlay.gpHUDLogCenter("Classified Documents and General Potter on Board!");
if (Action != null) Action.Do();
GamePlay.gpGetTrigger(shortName).Enable = false; // if trigger is TPassThru to avoid multiple activation
return; // leave method to avoid second call of the Action
}

if ("SAR2".Equals(shortName))
{
AiAction Action = GamePlay.gpGetAction("SAR2"); // if your action has an other Name than your trigger change GamePlay.gpGetAction(shortName) into GamePlay.gpGetAction("ActionName
GamePlay.gpHUDLogCenter("Classified Documents and General Potter Returned to Base! ");
if (Action != null) Action.Do();
GamePlay.gpGetTrigger(shortName).Enable = false; // if trigger is TPassThru to avoid multiple activation
return; // leave method to avoid second call of the Action
}

if (GamePlay.gpGetTrigger("SAR2").Active)
{
lnd = ++lnd; //increement lnd counter
//GamePlay.gpHUDLogCenter("SAR2:"+lnd);
}

if (GamePlay.gpGetTrigger("SAR").Active)
{
end = true;
//GamePlay.gpHUDLogCenter("SAR"); // define reached mission objective
}
}

public override bool IsMissionListener(int missionNumber)
{
return true;
}

private void checkLanded(AiAircraft aircraft)
{
if (GamePlay.gpPlayer().Place() != aircraft) return;
if ((end = true) && (lnd > 1)) // check landed, flown out of france and returned, reached mission objective
{
GamePlay.gpHUDLogCenter("General Potter and the Classified Documents have been Safely Recovered!");
}
}

public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
checkLanded(aircraft);
}
}