Official 1C Company forum

Official 1C Company forum (http://forum.1cpublishing.eu/index.php)
-   CoD Multiplayer (http://forum.1cpublishing.eu/forumdisplay.php?f=192)
-   -   New coop script (http://forum.1cpublishing.eu/showthread.php?t=34939)

41Sqn_Banks 10-13-2012 09:05 PM

New coop script
 
This new coop script doesn't use the mission menu, instead the commands are typed into the chat console. Thus the dummy aircraft are no longer needed.

Steps:
1) You must add the following line to your conf.ini or confs.ini (if you want to use the dedicated server):
Code:

[rts]
scriptAppDomain = 0

2) Create a new mission or use a existing single player mission
3) Add the following script to the mission:
Code:

using System;
using System.Collections.Generic;
using System.Text;

using maddox.game;
using maddox.game.world;

//$reference parts/core/gamePlay.dll

public class Mission : AMission
{
    public override void OnBattleInit()
    {
        base.OnBattleInit();

        if (GamePlay is GameDef)
        {
            (GamePlay as GameDef).EventChat += new GameDef.Chat(Mission_EventChat);
        }
    }

    void Mission_EventChat(IPlayer from, string msg)
    {
        if (msg.StartsWith("!help"))
        {
            Chat("Commands: !aircraft, !select#", from);
        }
        if (msg.StartsWith("!aircraft") || msg.StartsWith("!select"))
        {
            List<Tuple<AiAircraft, int>> aircraftPlaces = new List<Tuple<AiAircraft, int>>();
            if (GamePlay.gpArmies() != null && GamePlay.gpArmies().Length > 0)
            {
                foreach (int army in GamePlay.gpArmies())
                {
                    if (GamePlay.gpAirGroups(army) != null && GamePlay.gpAirGroups(army).Length > 0)
                    {
                        foreach (AiAirGroup airGroup in GamePlay.gpAirGroups(army))
                        {
                            if (airGroup.GetItems() != null && airGroup.GetItems().Length > 0)
                            {
                                foreach (AiActor actor in airGroup.GetItems())
                                {
                                    if (actor is AiAircraft)
                                    {
                                        AiAircraft Aircraft = actor as AiAircraft;
                                        for (int place = 0; place < Aircraft.Places(); place++)
                                        {
                                            aircraftPlaces.Add(new Tuple<AiAircraft, int>(Aircraft, place));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (msg.StartsWith("!aircraft"))
            {
                int i = 0;
                foreach (Tuple<AiAircraft, int> aircraftPlace in aircraftPlaces)
                {
                    string playerName = "";
                    Player player = aircraftPlace.Item1.Player(aircraftPlace.Item2);
                    if (player != null)
                    {
                        playerName = " " + player.Name();
                    }
                    Chat("#" + i + ": " + aircraftPlace.Item1.Name() + " " + aircraftPlace.Item1.TypedName() + " " + aircraftPlace.Item1.CrewFunctionPlace(aircraftPlace.Item2) + " " + playerName, from);
                    i++;
                }
            }
            else if (msg.StartsWith("!select"))
            {
                msg = msg.Replace("!select", "");

                int i = -1;
                if (int.TryParse(msg, out i) && i < aircraftPlaces.Count)
                {
                    Tuple<AiAircraft, int> aircraftPlace = aircraftPlaces[i];
                    if (aircraftPlace.Item1.Player(aircraftPlace.Item2) == null)
                    {
                        from.PlaceEnter(aircraftPlace.Item1, aircraftPlace.Item2);
                    }
                    else
                    {
                        Chat("Place occupied.", from);
                    }
                }
                else
                {
                    Chat("Please enter a valid aircraft number, e.g. !select0, !select1, !select2, ...", from);
                }
            }
        }
    }

    public void Chat(string line, IPlayer to)
    {
        if (GamePlay is GameDef)
        {
            (GamePlay as GameDef).gameInterface.CmdExec("chat " + line + " TO " + to.Name());
        }
    }
}

4) Host the mission. Clients have access to several commands by typing the command into the chat:

!help - this will show the available commands
!aircraft - this will show a list of all available aircraft starting with the id of the aircraft
!select# - this will place the player into the aircraft, replace # with the id of the aircraft, e.g. !select0 will place you into the first aircraft and so on.

41Sqn_Banks 10-13-2012 09:34 PM

1 Attachment(s)
I created an example mission, see attachment of this post.

SirAthlon 10-14-2012 02:27 AM

Nice Banks,i test it :grin:

Osprey 10-14-2012 08:21 AM

This looks excellent, thank you Banks. I don't understand all those whining saying there 'is no co-op' - they don't see the bigger picture from coding like this.

@Farber, you are sure to read this, do you think this would be useful for the multisquad campaign or aren't we quite there yet?

5./JG27.Farber 10-14-2012 09:11 AM

I would have to know how many people were turning up and set out all the aircraft. Would be more viable with a smaller group.

This looks like the best coop so far though. ;)

Skoshi Tiger 10-14-2012 12:11 PM

Downloaded the mission and played around with it this arvo. Although I've never played in a il2 Co-op I can see how it would work to let pilots join their flights and get into the action.

I guess the mission designer needs to put a lot of work into the briefings for the mission to get everyone up to full speed on their individual task and the overall objective(s) for the mission sorted out. Can they display waypoints for individual flight on the mission map?

Just one question. Would there be anyway for pilots to alter their loadout (or is this against the essence of being in a co-op)?

Cheers

41Sqn_Banks 10-15-2012 06:22 AM

Quote:

Originally Posted by Skoshi Tiger (Post 469392)
I guess the mission designer needs to put a lot of work into the briefings for the mission to get everyone up to full speed on their individual task and the overall objective(s) for the mission sorted out. Can they display waypoints for individual flight on the mission map?

Depending on your realism settings you can see the waypoints of the flight on the map, unfortunatly this setting also shows your own aircarft on the map.

There is hope that in the future it will be possible to create user labels within script. But this feature is still bugged in the latest RC.

Quote:

Just one question. Would there be anyway for pilots to alter their loadout (or is this against the essence of being in a co-op)?
There is no way. The loadouts can only be defined for the whole flight, not for individual aircraft. However that is not a big problem, typically the coop mission is designed for a specific loadout.

Ataros 10-15-2012 08:46 AM

Excellent news, many thanks Banks!

Is it possible to make an html(java?) file which when launched on a client PC would provide a GUI for this script? Hopefully data on already occupied seats can be transfered from server/other clients in real time (or on demand at least)?

bw_wolverine 10-25-2012 04:44 AM

This is great! Thank you, Banks.

Is there a way to set some aircraft so that they don't show up on the list of aircraft at start?

I suppose I could set the other aircraft to spawn on trigger so they aren't active in the game at the outset until someone triggers the spawn.

Palex 10-26-2012 02:57 AM

Thx for the script Banks....one question:

can i change the list of available planes when use !aircraft command?? e.g only red side.

Salute!

41Sqn_Banks 10-26-2012 11:42 AM

Both answers are yes, however I need to enhance the script. I hope I have time to do this next week.

bw_wolverine 10-26-2012 08:05 PM

Quote:

Originally Posted by 41Sqn_Banks (Post 473267)
Both answers are yes, however I need to enhance the script. I hope I have time to do this next week.

Awesome!

This is really a great piece of work and has totally revitalized No.401 Squadron in a big way.

We hope to use this script to help bring a CO-OP campaign to fruition. We're testing with the current version and signs are really good.

Punch_145 10-27-2012 01:33 PM

Very nice..Tried this and looks very promising only problem for me is if I use your script, Triggers and Actions seem to stop working? or am I doing something wrong?

dcheeze 10-28-2012 05:33 AM

I am unable to get the script to work, I've downloaded the example mission and loaded on my host machine (not dedicated server), started the mission as multiplayer (coop) and then have a client try and join the mission. The host is able to select an aircraft but the client, typing any of the three commands sees nothing. An following error is shown on the client machine: *WPF.Unavailable puppet place error. I'm not sure if I am doing this correctly so any help would be appreciated.

41Sqn_Banks 10-28-2012 06:58 AM

Quote:

Originally Posted by dcheeze (Post 473890)
I am unable to get the script to work, I've downloaded the example mission and loaded on my host machine (not dedicated server), started the mission as multiplayer (coop) and then have a client try and join the mission. The host is able to select an aircraft but the client, typing any of the three commands sees nothing. An following error is shown on the client machine: *WPF.Unavailable puppet place error. I'm not sure if I am doing this correctly so any help would be appreciated.

Did you add:
Code:

[rts]
scriptAppDomain = 0

to your conf.ini and confs.ini?
Is there any entry in the log file?

FG28_Kodiak 10-28-2012 08:02 AM

Quote:

Originally Posted by Punch_145 (Post 473629)
Very nice..Tried this and looks very promising only problem for me is if I use your script, Triggers and Actions seem to stop working? or am I doing something wrong?

You should add these lines to the script (insert it before the last bracket):
Code:

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

        AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
        if (action != null)
        {
            action.Do();
        }
       
    }

So the triggers and actions works like expected ;)

dcheeze 10-28-2012 10:02 AM

That was it, added the RTS scriptAppDomain and it worked like a charm. Thanks

Punch_145 10-28-2012 10:32 AM

Thank you Kodiak, Much appreciated :grin:

Punch_145 10-28-2012 11:06 AM

Sorry, when You say "before last bracket" do you mean like so?

Code:

using System;
using System.Collections.Generic;
using System.Text;

using maddox.game;
using maddox.game.world;

//$reference parts/core/gamePlay.dll

public class Mission : AMission
{
    public override void OnBattleInit()
    {
        base.OnBattleInit();

        if (GamePlay is GameDef)
        {
            (GamePlay as GameDef).EventChat += new GameDef.Chat(Mission_EventChat);
        }
    }

    void Mission_EventChat(IPlayer from, string msg)
    {
        if (msg.StartsWith("!help"))
        {
            Chat("Commands: !aircraft, !select#", from);
        }
        if (msg.StartsWith("!aircraft") || msg.StartsWith("!select"))
        {
            List<Tuple<AiAircraft, int>> aircraftPlaces = new List<Tuple<AiAircraft, int>>();
            if (GamePlay.gpArmies() != null && GamePlay.gpArmies().Length > 0)
            {
                foreach (int army in GamePlay.gpArmies())
                {
                    if (GamePlay.gpAirGroups(army) != null && GamePlay.gpAirGroups(army).Length > 0)
                    {
                        foreach (AiAirGroup airGroup in GamePlay.gpAirGroups(army))
                        {
                            if (airGroup.GetItems() != null && airGroup.GetItems().Length > 0)
                            {
                                foreach (AiActor actor in airGroup.GetItems())
                                {
                                    if (actor is AiAircraft)
                                    {
                                        AiAircraft Aircraft = actor as AiAircraft;
                                        for (int place = 0; place < Aircraft.Places(); place++)
                                        {
                                            aircraftPlaces.Add(new Tuple<AiAircraft, int>(Aircraft, place));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (msg.StartsWith("!aircraft"))
            {
                int i = 0;
                foreach (Tuple<AiAircraft, int> aircraftPlace in aircraftPlaces)
                {
                    string playerName = "";
                    Player player = aircraftPlace.Item1.Player(aircraftPlace.Item2);
                    if (player != null)
                    {
                        playerName = " " + player.Name();
                    }
                    Chat("#" + i + ": " + aircraftPlace.Item1.Name() + " " + aircraftPlace.Item1.TypedName() + " " + aircraftPlace.Item1.CrewFunctionPlace(aircraftPlace.Item2) + " " + playerName, from);
                    i++;
                }
            }
            else if (msg.StartsWith("!select"))
            {
                msg = msg.Replace("!select", "");

                int i = -1;
                if (int.TryParse(msg, out i) && i < aircraftPlaces.Count)
                {
                    Tuple<AiAircraft, int> aircraftPlace = aircraftPlaces[i];
                    if (aircraftPlace.Item1.Player(aircraftPlace.Item2) == null)
                    {
                        from.PlaceEnter(aircraftPlace.Item1, aircraftPlace.Item2);
                    }
                    else
                    {
                        Chat("Place occupied.", from);
                    }
                }
                else
                {
                    Chat("Please enter a valid aircraft number, e.g. !select0, !select1, !select2, ...", from);
                }
            }
        }
    }

    public void Chat(string line, IPlayer to)
    {
        if (GamePlay is GameDef)
        {
            (GamePlay as GameDef).gameInterface.CmdExec("chat " + line + " TO " + to.Name());
        }
    }
 public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);

        AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
        if (action != null)
        {
            action.Do();
        }
       
    }}


Nephris 10-28-2012 12:53 PM

Thx again for your work Banks.
Is there a way to limit the player spawn?
Means as soon as a player got shot, he is out.
Or better , can I seperate playable flights from non playable?

Would that only be possible by adding AI flights by loading submissions?

FG28_Kodiak 10-28-2012 01:35 PM

Quote:

Originally Posted by Punch_145 (Post 473964)
Sorry, when You say "before last bracket" do you mean like so?

Yes ;)

41Sqn_Banks 10-28-2012 01:39 PM

Quote:

Originally Posted by Nephris (Post 473993)
Thx again for your work Banks.
Is there a way to limit the player spawn?
Means as soon as a player got shot, he is out.
Or better , can I seperate playable flights from non playable?

Would that only be possible by adding AI flights by loading submissions?

At the moment no, but I think it's possible to add this. I will have a look at it next week.

@All: Thanks for the feedback, keep it coming. I will add the requested features as soon as possible.

bw_wolverine 10-28-2012 01:48 PM

Quote:

Originally Posted by FG28_Kodiak (Post 473917)
You should add these lines to the script (insert it before the last bracket):
Code:

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

        AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
        if (action != null)
        {
            action.Do();
        }
       
    }

So the triggers and actions works like expected ;)

Awesome. This might explain the weird behaviour we were seeing with AI. I'll toss this in and see if it fixes it.

Cheers!

No1 Cheese 10-28-2012 02:18 PM

Kodiak,hello mate :) this is helping a lot of people out here bud :)

Cheese

Palex 10-29-2012 10:32 PM

Quote:

Both answers are yes, however I need to enhance the script. I hope I have time to do this next week.
Thx Banks for the Answer, waiting for the update!!:grin:

Palex 11-16-2012 04:54 PM

Any news for this script?:grin:

Salutes!!

wippi 11-17-2012 10:08 AM

wpf.unavailable
 
Can somebody of you guys explain the whole thing in detail :confused:

We need your help http://forum.1cpublishing.eu/showthread.php?t=36037

David198502 11-17-2012 12:03 PM

i dont know what im doing wrong, but for me this is not working....
i put:

[rts]
scriptAppDomain = 0

in either my confs.ini and my conf.ini


but all the commands dont do anything once the mission is loaded.

what i noticed is, that the entry seems to get deleted automatically out of my conf.ini

EDIT:
ok after selecting the checkbox for read-only in for my conf.ini it suddenly worked...
however,...dont get me wrong, but what sense has this so called coop sricpt?
maybe i didnt fully understand it, or i miss something completely, but as soon as the host clicks " start battle", the mission will start, and all the ai airplanes will begin with their mission....so until players are ready, the battle might already be over...

HessleReich 03-26-2013 06:09 PM

Does this work with the Team Fusion Mod? i hve tested the old version (the ones with the Blenheims) and for some reason i cant ever select an aircraft to fly.

zoltann 07-15-2013 03:09 PM

WELL, does it work with TF 3.01?:confused:

Flying DESASTERSOFT Campaigns with buddies online would be so cool...

zoltann 07-15-2013 04:49 PM

Just tried this with above mentioned methods...no luck here.

This must be of interest to a lot of people, especially those flying with online squadrons.

:rolleyes:The potential with TF3.01...

zoltann 07-15-2013 05:32 PM

YESSS! I can fly COOP TF 3.01!

That is, I can convert ANY SP mission to COOP.

From now I can fly any DESASTERSOFT Campaign online with buddies!

Bloody beautiful!!!!

All you have to do is as mentioned before. What I did not grasp is that you only have to copy in a new .cs file (as provided as download in the beginning), rename it to your mission .cs and use that instead of the original (delete the original) .cs file of your SP. :grin::grin::grin:


All times are GMT. The time now is 07:03 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2007 1C Company. All rights reserved.