leguims / PS4Macro.PES2018Lite

Bot script for PES2018Lite using PS4 Macro
MIT License
5 stars 3 forks source link

Do not renew contracts in english version 'V1.0-pre2-en' #3

Closed leguims closed 6 years ago

leguims commented 6 years ago

hara88

I changed the code in the contract script so that the bot won't renew them. I have zero knowledge about scripting so sadly this is my maximum effort. I hope others can come in, test the bot and fix any issues found. Thanks for the amazing project!

leguims commented 6 years ago

First of all, I think it does not work because I lost original screenshots for "Match/AcceptNewContract*". That's why you try to imagine what kind of picture to capture. But you would have been really lucky guy to have the good ones ! :smile:

I will try to explain the code to help you to debug on your own PS4.

Each "script.MatchTemplate()" means macro is waiting for a new screen before to do next action.

I will explain code step by step for method OnMatched in file "AcceptNewContract.cs". If, this is not clear, ask me.

        public override void OnMatched(ScriptBase script)
        {
            bool manager = script.MatchTemplate(extensionManagerFocusHeader, 98);

The method OnMatched() is called for 2 reasons : renew player or renew manager. This line of code sets "manager" to "true" if the screen is similar to manager'screenshot and 'false' if not (which means for me : renew player).

manager will be use later.

            Log.LogMessage(Name, "Start");
            // List of player to renew
            script.Press(new DualShockState() { DPad_Right = false });
            script.Press(new DualShockState() { Circle = true });
            Log.LogMessage(Name, "Accept to renew players/Manager");

First screen to renew contracts : The game ask me to renew contracts. So I have to select "YES" by pressing "Right on digital PAD" and then press button "Confirm" (Circle in english, but Cross in french).

            // Cost and kind of money
            while (!script.MatchTemplate(script.CaptureFrame(), extension2Focus, 98))
            {
                Thread.Sleep(1000);
                Log.LogMessage(Name, "Waiting for 'Pay with GP money'");
            }

Then, I wait for the second screen "extension2Focus". So, this screen is a focus on the screen what appears after pressing "YES". Make the screenshot and take the good focus. Take the coordinates of french version to find where focus. Then update the "RectMap extension2Focus".

            script.Press(new DualShockState() { Circle = true });
            Log.LogMessage(Name, "Pay with GP money");

Second screen to renew contracts : The game show me cost to renew and ask me for the kind of money to use (in-game or real-one). So I choose "GP Money" (=in-game) to renew my players. In french version, I just have to press Cross button. In english, it could be Circle, but maybe you have to move with Right/Left DPAD.

            // Confirmation
            while (!script.MatchTemplate(script.CaptureFrame(), extension3Focus, 98))
            {
                Thread.Sleep(1000);
                Log.LogMessage(Name, "Waiting for 'Confirm'");
            }

Then, I wait for the third screen "extension3Focus". So, this screen is a focus on the screen what appears after pressing "GP Money". Make the screenshot and take the good focus. Take the coordinates of french version to find where focus. Then update the "RectMap extension3Focus".

            script.Press(new DualShockState() { DPad_Right = true });
            script.Press(new DualShockState() { Circle = true });
            Log.LogMessage(Name, "Confirm");

Third screen to renew contracts : The game ask me to confirm to buy. In french version, I just have to go to right and Confirm.

            // Transaction'status
            while (!script.MatchTemplate(script.CaptureFrame(), extension4Focus, 98))
            {
                Thread.Sleep(1000);
                Log.LogMessage(Name, "Waiting for 'Skip transaction status'");
            }

Then, I wait for the fourth screen "extension4Focus". Bla bla bla ... Make the screenshot and take the good focus ... :sleeping:

            script.Press(new DualShockState() { Circle = true });
            Log.LogMessage(Name, "Skip transaction'status");

Fourth screen to renew contracts : The game show me that previous transaction is OK. I just have to skip this screen.

            /* Only for manager */
            if (manager)
            {
                // Transaction'status 2
                while (!script.MatchTemplate(script.CaptureFrame(), extension5Focus, 98))
                {
                    Thread.Sleep(1000);
                    Log.LogMessage(Name, "Waiting for 'Skip transaction status2'");
                }
                // TODO : CAPTURE THE PICTURE !!
                Thread.Sleep(5000);
                script.Press(new DualShockState() { Circle = true });
                Log.LogMessage(Name, "Skip transaction'status2");
            }
            Log.LogMessage(Name, "End");
        }

This last part is only used, when you have to renew contract of manager ! Every 25 matchs ! (remember the variable manager at beginning). I tried to capture this screen "extension5Focus", but it was never similar and stops my macro. So I decide to wait 5 seconds instead ( with code Thread.Sleep(5000);). So I commented the "while" loop.

But if you have a good screenshot and if it works well, you can remove the sleep and uncomment the while loop.

Then I just press Cross in french to skip the screen.

I hope it helps you to understand the code and fix it.

leguims commented 6 years ago

But what's wrong ? To understand this, put "true" to your XML file "settings.xml" in the directory of "PS4Macro.exe". It will open a kind of DOS windows with lot of logs. But when time of renew players is coming (like the winter :cold_sweat:), it will show you information to find why the macro do not renew players !

When renew players works well, this sequence of logs will appears with my comments as [bla bla bla] :

    * Match : Accept New Contract Player/Manager : Start
    * Match : Accept New Contract Player/Manager : Accept to renew players/Manager
    * Match : Accept New Contract Player/Manager : Waiting for 'Pay with GP money'
[... could be repeated ...]
    * Match : Accept New Contract Player/Manager : Waiting for 'Pay with GP money'
    * Match : Accept New Contract Player/Manager : Pay with GP money
    * Match : Accept New Contract Player/Manager : Waiting for 'Confirm'
[... could be repeated ...]
    * Match : Accept New Contract Player/Manager : Waiting for 'Confirm'
    * Match : Accept New Contract Player/Manager : Confirm
    * Match : Accept New Contract Player/Manager : Waiting for 'Skip transaction status'
[... could be repeated ...]
    * Match : Accept New Contract Player/Manager : Waiting for 'Skip transaction status'
    * Match : Accept New Contract Player/Manager : Skip transaction'status
[ "Skip transaction'status2" is only when renew manager, it is optionnal ! ]
    * Match : Accept New Contract Player/Manager : Skip transaction'status2 [optionnal !]
    * Match : Accept New Contract Player/Manager : End

With your logs, you can compare to this perfect treatment and deduce where something is wrong. Then, you can share it here, and I can help you to fix it.

hara88 commented 6 years ago

Leguims, I'm very sorry to cause you this confusion. I don't have any issues regarding contract renewal for players and managers. Using the screenshots that I have taken, the bot can do the contract renewals without any trouble, both for the player and manager.

Log.LogMessage(Name, "Start"); // List of player to renew script.Press(new DualShockState() { DPad_Right = false }); script.Press(new DualShockState() { Circle = true }); Log.LogMessage(Name, "Accept to renew players/Manager");

I deliberately changed the DPad_Right to false because I don't want to pay for the contracts for white/bronze players. If I change it back to true the bot will renew the contracts no problem. I do this because I don't want to pay about 4000 GP for the contracts, I just spin new players from the free scouts. And by releasing the players after 10 games I get about 2000 GP so there is about 6000 GP difference there.

Again, I'm sorry for the trouble caused by the misunderstanding. There is no issue regarding automatic contract renewal. I actually used the automatic contract renewals for the first 2 days of the macro and then I changed the farming method to not buy the contracts.

leguims commented 6 years ago

No problem. That's ok. This is my mistake. Don't worry. :grinning:

leguims commented 6 years ago

"I changed the code in the contract script so that the bot won't renew them. I have zero knowledge about scripting so sadly this is my maximum effort. I hope others can come in, test the bot and fix any issues found." Did you need something you can not do ?

hara88 commented 6 years ago

What I meant by this is that the macro works good for me and it can perform all the functions required. But I can only say for myself that's why I think we need feedback from other users to perfect the macro 😀

leguims commented 6 years ago

Ok. I understand. I have to change the code to enable the renew.

leguims commented 6 years ago

I change the code to enable renewals. Thanks for all you did. There is a V1.0-en tag for PES EN ! Good Job !