![]() |
Script limiting aircraft types (including multilingual messages)
Here is a current WIP script version from Repka Steppe map. Kodiak and TheEnlightenedFlorist, thank you for your help. Without you it would not be possible.
The script runs on Repka #1 ATM please try it and let me know what you think. Kodiak, when you have time I would like to ask you for advice how to calculate number of enemy fighter and bomber planes. Ideally I see aircraft limiting script as follows: Declare percentages for limited aircraft types = X%. OnPlaceEnter recalculate number of human-controlled enemy fighter and bomber planes (enmyFgtrs & enmyBmbrs) - this is the difficult part :) Set curTeamBalance = (friendlyFgtrs + friendlyBmbrs/2) / (enmyFgtrs + enmyBmbrs/2) Check if if curTeamBalance > allowedTeamBalance then deny a limited aircraft (with RU and international message). else Set e.g. Code:
allowed109s = (X% * (enmyFgtrs + enmyBmbrs/2) * objCompleted) / curTeamBalance Check if (current109s > allowed109s) then deny an aircraft. Leave a window of opportunity for other players to take a limited aircraft after a player that just flew a limited aircraft takes it again (I do it in code reducing current109s by 1 for 20 seconds and then increasing it again). I know that other servers experience huge issues trying to find balance between SpitIIs and 109s and this script may be very useful for everyone flying online. Code:
using System; Regarding messages script it looks like a RU message would be shown to everyone if using sendChatMessageTo(-1, ru, ...) sendChatMessageTo(-1, null, ...) shows international message to RU users. Ideally I would like to separate messages to RU and international users completely if possible. |
Quote:
Ok my fault :sad:, have forgotten to handle different languages if send on all. Corrected version: Code:
private void sendScreenMessageTo(int army, string playerlanguage, string msg, object[] parms) Quote:
Should the script calculate all in game planes too, or only the player controlled? So it should be possible to disable KI Starts if many Players are online. |
Quote:
Sorry did not get what you mean by KI Starts? If you mean AI, I do not want to limit AI flights. Thank you very much again. |
German KünstlicheInteligenz = English ArtificialIntelligence
just a little language mismatch ;) |
I see a little problem
How to handle if one side don't have human pilots. Then your formula tries a division by zero and this will results in an error. |
Quote:
Or maybe divide (1 + friendlyFgtrs + friendlyBmbrs/2) / (1+ enmyFgtrs + enmyBmbrs/2). It will do. Or we can deny premium planes at all if say other side has less than 2 human players. edit What I do not know is how to handle other side players which are still in the menu and not flying. Can they be taken into account? If yes, probably 80% of them should be accounted as fighters and 20% as bombers if you do not mind. But it is not very important I think. |
1 Attachment(s)
It looks I am in trouble with my script here too.
Again it works for hosted server killing my engine when required but does not work on dedicated server. First I used this line as you can see above in my message Code:
(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure); Then I tried to modify actor-damaging script to destroy player plane. The same thing happens. On a dedicated server this script damages abondoned aircrat but my modified methods do not work. But work on hosted server (when I am the server). OnPlaceEnter check where damagePlayerGroup((actor as AiAircraft)) does not work on a dedi. Code:
//checks limited aircraft Code:
#region Destroy Actors Methods |
Its a bug in dedi. As Workaround i use in my penalty script:
Code:
private void DoDamageToAirplane(AiAircraft aircraft) At the moment i working on a script, which remove and add planes (on the fly) to the birthplaces, so its no longer nessesary to damage 'overused' planes. But in the moment its in a early stage. |
Thank you!
Maybe you can get Length of LimbNames.Tail from the game same as with engines here and run a loop? Tail would do the job in the air too I think. Code:
int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum(); |
1 Attachment(s)
1.11 version up on Repka #3 for testing
|
I have a more general question which I hope someone can answer:
My mission loads submission with some parameters (attacker army, mission type, attack sector, etc), then gets trigger status, calculates mission results and shows results messages using the same parameters. It goes fine when submissions are loaded one by one. I want to add different types of submissions and make them overlap in time. Naturally I have to store parameters of every submissions as different variables to prevent them mixing up. How can I do this? Should I create a list for each parameter and send it to array when each new submission loads or there is a more elegant way to do this. I will not have more then 10 submissions going on simultaneously and do not have to create arrays with the length of total past submissions quantity. |
Make a class with all infos you need and then store the objects in a list.
For example : Code:
using System; |
Thank yoг for a good example. I will try creating a class for my needs and will come back with more questions if any.
S! |
1 Attachment(s)
I did the exercise, sure with many mistakes but will do some reading on classes creation to correct them.
However I am stuck in OnTrigger method completely. I have several submissions running at the same time with the same filenames and the same trigger names. This happens because they are randomly loaded and the same submission can be loaded 2-4 times within an hour. How can I identify which trigger of which submission is triggered OnTrigger? I number my missions as "mi.MisMissionNumber" but their numbers are different from OnTrigger "missionNumber". The file is renamed to a .txt. If you have time to answer other questions I will appreciate it. |
Will take a look at it.
Short answers: Code:
public static string SubMissionsPath = @"missions\Multi\Dogfight\r_steppe\subs\"; Code:
// what does this block do? So i can use Code:
public List<Mis> MissionPool = new List<Mis>() // You use mi.Missionfilename instead of mi.Filename in your example when load missions. Why? I use the public method Missionfilename to get access to the variable in the object. Filename is only used in the constructor to give the value to the variable Missionfilename. More to come, must take a deeper look at it, but no time at the moment. But it seems you think a bit too complicated ;) |
Quote:
this.MissionLengh = 30; Ah, it looks like the only purpose of it is to allow data input like here: Code:
public List<Mis> MissionPool = new List<Mis>() mi.Missionfilename = ...; mi.SubMissionsPath = ...; mi.MissionLengh = ...; Instead after parsing a file name I can: Code:
string[] MisParams; |
first sorry for bumping an old thread.
im facing an issue implementing a "similar" (based) on this method script. my issue is, with multi-sit aircriaft. when you spawn in one of those and change seats with will result in decrease of 1 to the pool by each seat. much of the following CODE is not mine (around 90%) so no credit for it. Credit goes for Ataros, Kodiak, and some other guys, i cant recall everyone i steal from :grin: Quote:
|
You can check if a player is already in a plane
Code:
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex) or you check PlaceSecondary, PlaceSecondary is -1 if a player is 'new' in a plane, if not new PlaceSecondary gets the value of the last secondary place. Code:
if (player.PlaceSecondary() != -1) |
A bit unrelated to the actual discussion, but what you say about primary and secondary places confirms my observations about AI gunners.
We all know that if you switch to a gunner position the AI no longer mans the turret. Flying a Blenheim on ATAG one night, i happened to find out completely by chance that if your aircraft has a bombardier position you can give back gun control to the AI: simply cycle between pilot and bombardier once and your gunners will revert to AI control. This was also reflected on the net stats overlay, where next to my nickname i could see "pilot, gunner" initially and "pilot, bombardier" after cycling positions. Thanks for confirming my suspicions ;) |
thank you!
Worked like a charm! |
Hi, still on the same topic, yet a differente type of code, im tryign to get a submenu to have an option to refly.
code Quote:
sorry, but im really noob in C# |
you get the Aircraft via player.Place()
Code:
if (player.Place() != null && player.Place() is AiAircraft) |
Thnak you Kodiak, will try that when i get home.
Where do you get all of this info? of what info is stored in wich class? and wich classes can be converted to others? from trial and error, and from seeing other people i get to learn some of them ( actor can be used as aircraft and such), but where does this knowledge comes from? trial and error? |
Object-Explorer in Visual Studio and try and error (sometimes Cliffs don't react as expected :rolleyes:).
|
Can any of You guys update "plane limit" script that`s working 100% on dedi server pleas...
|
Don't know if this script working 100% at Dedi Server (theoretical it should :rolleyes:), have not the time to test it properly so it's on you ;):
Code:
using System; |
thanx Kodiak will check it today evening...
|
Tested, works fine so far. You cant spawn the plane so it`s not causing spamming on the runway.... Thanx again Kodiak
|
All times are GMT. The time now is 01:47 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.