PDA

View Full Version : OnStationaryKilled army



_1SMV_Poppy_64
Oct-13-2014, 06:36
Hi all,

someone may help me to find the ARMY of a stationary killed instead the COUNTRY?

public override void OnStationaryKilled(int missionNumber, GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)

infact, I can find only _stationary.country but not the army, it is different!

Thank you!

Salmo
Oct-13-2014, 07:50
Hi all,

someone may help me to find the ARMY of a stationary killed instead the COUNTRY?

public override void OnStationaryKilled(int missionNumber, GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)

infact, I can find only _stationary.country but not the army, it is different!

Thank you!
Another example of how different programers in the development cycle used different methods to construct the objects. You're right, aircraft have "armies" numbers (0, 1, 2 for none, red & blue) while stationary objects have countries alphabet codes (de, gb, nn for German, Great Britain & None). You'll need to parse the country and assign the correct army number.



public override void OnStationaryKilled(int missionNumber, GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
{
int army = GetArmyNumberFromCountryCode(_stationary.country);
// army now contains the correct army number
// ..... your code here

}

public int GetArmyNumberFromCountryCode(string country)
{
int army = 0; // default is no army
if (_stationary.country.Contains("gb")) army = 1; // red Allies army
if (_stationary.country.Contains("de")) army = 2; // blue German army
if (_stationary.country.Contains("it")) army = 2; // blue Italian army
return army;
}

public int GetCountryCodeFromArmyNumber(int army)
{
string country = "nn"; // default is no army
if army == 1) country = "gb"; // red Allies army
if (army == 2) country = "de"; // blue German army
return country;
}

ATAG_Lolsav
Oct-13-2014, 08:01
if (_stationary.country.Contains("gb")) army = 1;



Forgive if the question makes no sense Salmo. On code language, to check a value, shouldnt have a double equal sign insted? Meaning, to check if condition is true shouldnt be
if (_stationary.country.Contains("gb")) army == 1;

Salmo
Oct-13-2014, 08:18
Forgive if the question makes no sense Salmo. On code language, to check a value, shouldnt have a double equal sign insted? Meaning, to check if condition is true shouldnt be
if (_stationary.country.Contains("gb")) army == 1;

Hello Lolsav. You are correct in saying that you use a double equal sign to check for equality inside an 'if' statement condition. However, in the above example the .Contains("gb") is the 'if' condition being checked, while if the condition is true then we set the army variable equal to 1. Thus army = 1 is the correct syntax. I'll expand the if statement so it makes sense ....



if (_stationary.country.Contains("gb"))
{
army = 1;
}

is the same as writing ....


if (_stationary.country.Contains("gb")) army = 1;

ATAG_Lolsav
Oct-13-2014, 09:29
Thanks for the explanation. Btw i think theres a missing bracket on your first post "("

Where:


public int GetCountryCodeFromArmyNumber(int army)
{
string country = "nn"; // default is no army
if (army == 1) country = "gb"; // red Allies army
if (army == 2) country = "de"; // blue German army
return country;
}

_1SMV_Poppy_64
Oct-13-2014, 11:05
Correct, but there is a little problem:

if a mission is made with a static object selected from a list of german object and the army assigned in mission builder is for example red, there is no way to see in the eventlog the army and not the country... so, the parsing will be wrong...

we are close to have a stats complete, see http://www.1smv.it/public/1SMV_Stats_Cod/ , this is a beta.

Ciao!

ATAG_Lolsav
Oct-13-2014, 11:13
Very promising stuff there _1SMV_Poppy_64, hope it goes all ok :)

Now about your question: The problem is if a german AA controlled by a british operator would, that got destroyed, would be counted as a german loss if it got destroyed.

As far as i know, in AI world, the controler defines the side, ie, doesnt matter the vehicle but the vehicle controler side. But this is something you can test on your own i guess. If im right you have your problem solved. If im wrong you need to dig up a better solution :)

VII.Racetrack
Oct-13-2014, 11:43
And what about the Static NOT CONTROLLABLE object?

For example what happen if an ammo crate that is White Side by default but setted as Red in FMB?

If it got destroyed would be a Red loss?
Or it will be NOT counted due to the default membership to the white side?

And what about objects that belong for default to the red side but changed as member of the blue?

If a Blue destroy them would be counted as a Enemy loss or Frendly loss?


Sry for english, I'm trying to contribute...

bb

ATAG_Lolsav
Oct-13-2014, 11:48
And what about the Static NOT CONTROLLABLE object?

Thats a very good point. So i point to a solution in a diffrent way: What about a trigger over England and other over France to see if a object was destroyed? I know friendlies could also destroy it, but it would count as a loss i guess.

Can the trigger check who activates it? Meaning, can the destroyed object check who has destroyed it? Friend or foe?

Salmo
Oct-14-2014, 00:09
public override void OnStationaryKilled(int missionNumber, GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
{
int army = GetArmyAtPoint(_stationary.pos.x, _stationary.pos.y); // assumes front lines
// army now contains the correct army number
// ..... your code here

}

public int GetArmyAtPoint(double x, double y)
#region returns the army number at the specified point
{
int result = 0;
result = GamePlay.gpFrontArmy(x, y);
return result;
}
#endregion

_1SMV_Poppy_64
Oct-15-2014, 08:13
public override void OnStationaryKilled(int missionNumber, GroundStationary _stationary, AiDamageInitiator initiator, int eventArgInt)
{
int army = GetArmyAtPoint(_stationary.pos.x, _stationary.pos.y); // assumes front lines
// army now contains the correct army number
// ..... your code here

}

public int GetArmyAtPoint(double x, double y)
#region returns the army number at the specified point
{
int result = 0;
result = GamePlay.gpFrontArmy(x, y);
return result;
}
#endregion




Ok, thank you all. I added in my code a parsing: if the country of the object is GB the army is 1 and so on, if country is nn, the army is the same of the front lines.
I'll write in this forum more question, just to complete the stats generator, ops I have a new question... I'm going to post a new one...:D

Thank you again.:)