ATAG_Ezzie
Oct-18-2014, 18:28
Hi,
Bolox et al have been assisting me re getting going re scripting in a couple of threads in this forum. But rather than continue to hijack Salmo's random weather thread I've created this thread in which I've loaded my first go at developing a script. I would have first tested this in FMB but unfortunately my PC is not letting me use it (should be fixed mid-week hopefully) so thought i would post it here and get advice on how it looks. And then once my PC is back working give it a go and see what happens.
In order to to test my understanding I'm going to try and describe what is happening (this might be helpful for other script learners?) and hopefully if i'm wrong someone will kindly point out the errors/misconception. Here goes
(a) Using: This just defines the libraries that will be used by the various script 'commands' contained in the script. These are what COD uses to do its stuff under the hood (noting there are probably various levels of 'under the hood')
(b) AMission: Not exactly sure but this seems to be present on most scripts I've seen. I think it says that what follows is a class/mission called AMission and COD recognises this and reacts according to what the script goes on to do
(c) Listen to events of every mission: Again this seems to be a common line in a lot of scripts i have seen. Not 100% sure but it seems to initialise something that keeps track of all msgs issues by the game and the script then uses these messages to do stuff.
(d) public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft): This line creates a class called OnAircraftTookOff- according to my book a class is bundling of unlike data and functions that belong together in one tidy package. So OnAircraftTookOff is a class and its associated data/functions/parameters are int missionNumber (not sure where this comes from - perhaps generated by the game?), string shortname (again not sure where this variable comes from) and AiAircraft aircraft (huh?). Maybe every time an aircraft takes off it get assigned these variable which is carries with it for the rest of its flight?
(e) base.OnAircraft... This is member of the OnAircraftTookOff class - i think? I'm totally guessing here but am thinking that this says when an aircraft takes off it takes note of the aircraft's details (mission number, short name and aircraft type) - this is where i lose track of what is happening (assuming i knew what was happening before this point)
(f) GamePlay.gpHUDLogCenter. This seems to be the command to generate the HUD message. I'm guessing we have no control over how the HUD message looks and it is displayed for a set time before it goes away (I havent seen anything that says 'display HUD message for a certain time before removing it - but maybe there is a way to do this?).
So I'm hoping the above says that when an aircraft takes off a HUD msg is generated saying 'Nice take off'. And i'm thinking that everytime an aircraft takes off it creates a public class called onAircraftTakeOff with a set of unique identifiers - mission name, shortname and aircraft type)?
Like i said above ordinarily i would have tested this to see if it works (pretty good chance it wont) but because of my PC issues i wasnt able to. But I'm hoping that because its a relatively simple (for an experienced coder - there is no such thing as a simple script for me yet) script then someone will be able to easily correct my thinking/code.
Thanks in advance for any assistance.
Ezzie
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
public class Mission:AMission
{
//Listen to events of every mission
public override void Init(maddox.game.ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1; //Listen to events of every mission
}
//Generation of HUD msg on take off
public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff(missionNumber, shortName, aircraft);
GamePlay.gpHUDLogCenter("Nice take-off");
}
//generation of HUD msg on landing
public override void OnAircraftLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
GamePlay.gpHUDLogCenter("Nice landing");
}
}
Bolox et al have been assisting me re getting going re scripting in a couple of threads in this forum. But rather than continue to hijack Salmo's random weather thread I've created this thread in which I've loaded my first go at developing a script. I would have first tested this in FMB but unfortunately my PC is not letting me use it (should be fixed mid-week hopefully) so thought i would post it here and get advice on how it looks. And then once my PC is back working give it a go and see what happens.
In order to to test my understanding I'm going to try and describe what is happening (this might be helpful for other script learners?) and hopefully if i'm wrong someone will kindly point out the errors/misconception. Here goes
(a) Using: This just defines the libraries that will be used by the various script 'commands' contained in the script. These are what COD uses to do its stuff under the hood (noting there are probably various levels of 'under the hood')
(b) AMission: Not exactly sure but this seems to be present on most scripts I've seen. I think it says that what follows is a class/mission called AMission and COD recognises this and reacts according to what the script goes on to do
(c) Listen to events of every mission: Again this seems to be a common line in a lot of scripts i have seen. Not 100% sure but it seems to initialise something that keeps track of all msgs issues by the game and the script then uses these messages to do stuff.
(d) public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft): This line creates a class called OnAircraftTookOff- according to my book a class is bundling of unlike data and functions that belong together in one tidy package. So OnAircraftTookOff is a class and its associated data/functions/parameters are int missionNumber (not sure where this comes from - perhaps generated by the game?), string shortname (again not sure where this variable comes from) and AiAircraft aircraft (huh?). Maybe every time an aircraft takes off it get assigned these variable which is carries with it for the rest of its flight?
(e) base.OnAircraft... This is member of the OnAircraftTookOff class - i think? I'm totally guessing here but am thinking that this says when an aircraft takes off it takes note of the aircraft's details (mission number, short name and aircraft type) - this is where i lose track of what is happening (assuming i knew what was happening before this point)
(f) GamePlay.gpHUDLogCenter. This seems to be the command to generate the HUD message. I'm guessing we have no control over how the HUD message looks and it is displayed for a set time before it goes away (I havent seen anything that says 'display HUD message for a certain time before removing it - but maybe there is a way to do this?).
So I'm hoping the above says that when an aircraft takes off a HUD msg is generated saying 'Nice take off'. And i'm thinking that everytime an aircraft takes off it creates a public class called onAircraftTakeOff with a set of unique identifiers - mission name, shortname and aircraft type)?
Like i said above ordinarily i would have tested this to see if it works (pretty good chance it wont) but because of my PC issues i wasnt able to. But I'm hoping that because its a relatively simple (for an experienced coder - there is no such thing as a simple script for me yet) script then someone will be able to easily correct my thinking/code.
Thanks in advance for any assistance.
Ezzie
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
public class Mission:AMission
{
//Listen to events of every mission
public override void Init(maddox.game.ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1; //Listen to events of every mission
}
//Generation of HUD msg on take off
public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftTookOff(missionNumber, shortName, aircraft);
GamePlay.gpHUDLogCenter("Nice take-off");
}
//generation of HUD msg on landing
public override void OnAircraftLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
GamePlay.gpHUDLogCenter("Nice landing");
}
}