Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > CoD Multiplayer

CoD Multiplayer Everything about multiplayer in IL-2 CoD

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2011, 04:04 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default Script to Remove AI From Servers

From now on, all my guides will be hosted on Airwarfare.com. This way I only have to edit one document. You may still post suggestions and corrections in this thread.

http://airwarfare.com/sow/index.php?...=539&Itemid=54

Last edited by TheEnlightenedFlorist; 07-01-2011 at 11:21 PM.
Reply With Quote
  #2  
Old 06-06-2011, 08:07 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Is there a way to include all the above code parts into just one method like clearAircraft(general timeout, optional aircraft landing timeout, optional aircraft abandoned timeout, optional aircraft crashlended timeout) and call it in just 1 line from existing game methods? The code would then automatically understand which method it is called from and act accordingly. I assume new code can not call the existing game methods itself and we have to put at least one line in existing game methods (onTrigger, ontickgame, etc.)

It would make life of server owners much easier. I am just starting to learn C# and is interested to learn how to make code more readable and usable as encapsulated building blocks. It would be perfect to have just one code block per function.
Reply With Quote
  #3  
Old 06-06-2011, 01:49 PM
SYN_Flashman SYN_Flashman is offline
Approved Member
 
Join Date: Feb 2011
Posts: 48
Default

Hi enlightened,

I pretty much use that script for despawning on my missions over at Syndicate including listen to mission events. I just adjusted the time for plane removal downwards (to 1 minute)

It appears to work fine, we just have the problem with multicrew aircraft turning the engine temps to zero when switching seats. I have tried the server without the script (since the last patch included aircraft removal on landing) but the problem is that if a player leaves a plane before takeoff AI takes over, takes off and then loiters around the field for hours!

Anyhow, hopefully the next patch will address the crew change issue.
Reply With Quote
  #4  
Old 06-07-2011, 12:01 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

I added code to the script to deal with aircraft with more than two engines. Courtesy of ZaltysZ.

Quote:
Originally Posted by SYN_Flashman View Post
Hi enlightened,

I pretty much use that script for despawning on my missions over at Syndicate including listen to mission events. I just adjusted the time for plane removal downwards (to 1 minute)

It appears to work fine, we just have the problem with multicrew aircraft turning the engine temps to zero when switching seats. I have tried the server without the script (since the last patch included aircraft removal on landing) but the problem is that if a player leaves a plane before takeoff AI takes over, takes off and then loiters around the field for hours!

Anyhow, hopefully the next patch will address the crew change issue.
I swear I remember this bug, but I just went through every German aircraft with more than one position and couldn't reproduce it. The engine stuttered a little (could just be a sound bug), but the temperatures remained the same.
Reply With Quote
  #5  
Old 06-07-2011, 12:17 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Quote:
Originally Posted by Ataros View Post
Is there a way to include all the above code parts into just one method like clearAircraft(general timeout, optional aircraft landing timeout, optional aircraft abandoned timeout, optional aircraft crashlended timeout) and call it in just 1 line from existing game methods? The code would then automatically understand which method it is called from and act accordingly. I assume new code can not call the existing game methods itself and we have to put at least one line in existing game methods (onTrigger, ontickgame, etc.)

It would make life of server owners much easier. I am just starting to learn C# and is interested to learn how to make code more readable and usable as encapsulated building blocks. It would be perfect to have just one code block per function.
To be honest, it can't get too much simpler than it is already. You are right that there needs to be at least one line of code in the methods and that's the way it is already. We have one line of code in the OnPlaceLeave() method and on the AircraftLanded() and AircraftCrashLanded() methods and of course the mission number listener.

I'm not an expert in software development, but I was taught that you don't want to cram too much code into one method. It's better to separate it out into parts so it's easier to read and modify.
Reply With Quote
  #6  
Old 06-07-2011, 07:44 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by TheEnlightenedFlorist View Post
I swear I remember this bug, but I just went through every German aircraft with more than one position and couldn't reproduce it. The engine stuttered a little (could just be a sound bug), but the temperatures remained the same.
I think you have it solved with the following code. Did you check it on a dedicated server? I included it in my script too but did not check yet as struggling with ground attacks code atm.

Code:
        //check if a player is in any of the "places"
        for (int i = 0; i < aircraft.Places(); i++)
            if (aircraft.Player(i) != null)
                return false;
Does aircraft.Player() return a player name located inside an AiAircraft?
Do you know when RemotePlayer has to be used instead of Player?
Reply With Quote
  #7  
Old 06-07-2011, 08:32 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Quote:
Originally Posted by Ataros View Post
Does aircraft.Player() return a player name located inside an AiAircraft?
Do you know when RemotePlayer has to be used instead of Player?
It returns the player at a specific "place" in an aircraft. It looks like "places" is what the developers call different seats in aircraft. If there is no player in that seat, it returns null.

gpRemotePlayers() would be used to get all of the players connected to the server. From there, you could get the aircraft that they are in. aircraft.Player() would be used when you already have an aircraft and want to get the player (if any) that occupies that aircraft. It's a subtle but very important difference.
Reply With Quote
  #8  
Old 06-07-2011, 11:06 AM
SYN_Flashman SYN_Flashman is offline
Approved Member
 
Join Date: Feb 2011
Posts: 48
Default

Quote:
Originally Posted by TheEnlightenedFlorist View Post
I added code to the script to deal with aircraft with more than two engines. Courtesy of ZaltysZ.



I swear I remember this bug, but I just went through every German aircraft with more than one position and couldn't reproduce it. The engine stuttered a little (could just be a sound bug), but the temperatures remained the same.
AFAIK this only happens on dedicated servers when online hence the difficulty in tracking it down! It certainly happens on the Syndicate Server. I will have a look at some of the extra bits of code and do some testing on our server when I get the opportunity.
Reply With Quote
  #9  
Old 06-08-2011, 02:11 AM
TheEnlightenedFlorist TheEnlightenedFlorist is offline
Approved Member
 
Join Date: May 2011
Location: SLC, Utah, USA
Posts: 143
Default

Quote:
Originally Posted by SYN_Flashman View Post
AFAIK this only happens on dedicated servers when online hence the difficulty in tracking it down! It certainly happens on the Syndicate Server. I will have a look at some of the extra bits of code and do some testing on our server when I get the opportunity.
Yep. Only happens on dedicated servers.
Reply With Quote
  #10  
Old 06-11-2011, 06:23 PM
pirke pirke is offline
Approved Member
 
Join Date: Aug 2010
Posts: 30
Default

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}

public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}

private bool isAiControlledPlane(AiAircraft aircraft)
{
if (aircraft == null)
return false;

//check if a player is in any of the "places"
for (int i = 0; i < aircraft.Places(); i++)
if (aircraft.Player(i) != null)
return false;

return true;
}

private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
aircraft.Destroy();
}

private void damageAiControlledPlane(AiActor actorMain)
{
foreach (AiActor actor in actorMain.Group().GetItems())
{
if (actor == null || !(actor is AiAircraft))
return;

AiAircraft aircraft = (actor as AiAircraft);

if (!isAiControlledPlane(aircraft))
return;

if (aircraft == null)
return;

aircraft.hitNamed(part.NamedDamageTypes.ControlsEl evatorDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsAi leronsDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsRu dderDisabled);
aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFa ilure);
int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
aircraft.hitNamed((part.NamedDamageTypes)Enum.Pars e(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}


Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
}





all is good but ......

When a player abandons a plane, script will disable controls and engines and remove the plane after 300 seconds.

this not working

AI continue to fly with no restriction

pls some help with this part only

THNKS
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:06 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.