Staredit Network > Forums > Modding Assistance > Topic: I made SCVs harvest the same mineral patch forever...
I made SCVs harvest the same mineral patch forever...
Aug 5 2021, 2:07 pm
By: Netbek  

Aug 5 2021, 2:07 pm Netbek Post #1



I made it so that when a worker is ordered to harvest minerals, it will forever harvest from the targeted ore chunk without ever returning to a building (the income is generated via GPTP plugin while the unit harvests).
Firegraft Settings

The problem: When AI is given "Area Town" in the editor, their SCVs will pause for 20 seconds every 60 seconds.
VIDEO
mini mod for testing it

Post has been edited 3 time(s), last time on Aug 8 2021, 9:19 am by Netbek.




Aug 7 2021, 7:45 am Nekron Post #2



AI will need breaks in between mining to check when new buildings can be setup up since that happens on cargo return, but... Does this even work with AI at all? Can it build?




Aug 7 2021, 9:43 am Netbek Post #3



Quote from Nekron
Does this even work with AI at all? Can it build?
The AI in my mod does not need to build stuff. For now, the only thing it needs to do, is have its workers harvest forever.




Aug 10 2021, 11:32 am Netbek Post #4



Still no solution. Some ideas:
- Is there a way to make harvesters instantly "return" the carried resource piece at the location where they are?
- Is there a way to decrease how close they have to be to the building they return to.




Aug 10 2021, 11:43 am UndeadStar Post #5



In orders_ReturnHarvest, maybe you should try moving the
Code
                    u8 orderId;

                    if (unit->pAI != NULL)
                        orderId = OrderId::ComputerAI;
                    else
                    if(unit->resourceType != ResourceCarried::Vespene)
                        orderId = OrderId::MoveToMinerals;
                    else
                        orderId = OrderId::HarvestGas1;

                    if (unit->worker.targetResource.unit != NULL)
                        function_00474A70(unit, unit->worker.targetResource.unit, orderId);
                    else
                        orderImmediate(unit, orderId);

                    unit->orderToIdle();

                    function_004F39A0(unit);

                    if (unitTypeIsHatcheryType(target))
                        function_004E92B0(unit, target);
part to replace
Code
                if (orderToMoveToTarget(unit, target))
                    unit->mainOrderState = 1;

above that make the unit move until reaching the resource depot or until being unmovable somehow




Aug 12 2021, 6:26 pm Netbek Post #6



Quote from UndeadStar
In orders_ReturnHarvest [...]
I cannot find orders_ReturnHarvest in GPTP. I use GPTP-For-VS2008-Update-4. Am I overlooking something?




Aug 12 2021, 6:50 pm Voyager7456 Post #7

Responsible for my own happiness? I can't even be responsible for my own breakfast

Yes, the newest GPTP can be found here: https://github.com/BoomerangAide/GPTP



all i am is a contrary canary
but i'm crazy for you
i watched you cradling a tissue box
sneezing and sniffling, you were still a fox


Modding Resources: The Necromodicon [WIP] | Mod Night
My Projects: SCFC | ARAI | Excision [WIP] | SCFC2 [BETA] | Robots vs. Humans | Leviathan Wakes [BETA]


Aug 16 2021, 1:44 pm Netbek Post #8



Quote from UndeadStar
[...]
This works exactly as I wanted, thank you!
I had to switch from GPTP-For-VS2008 (Visual Studio 2008) to GPTP-master (Visual Studio 2019) for this. It could be a bit tedious to copy over everything I had changed into the new version. Is there an elegant way, maybe even automatic? (new thread here)

Sidenote for future readers:
Quote from UndeadStar
[...]above that make the unit move until reaching the resource depot or until being unmovable somehow
I did not need this, the code UndeadStar posted solved the problem without any further steps.


Post has been edited 1 time(s), last time on Aug 16 2021, 1:51 pm by Netbek.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[07:40 am]
Ultraviolet -- :wob:
[2021-10-26. : 10:31 pm]
RIVE -- :wob:
[2021-10-25. : 9:59 pm]
UndeadStar -- :wob:
[2021-10-25. : 8:39 pm]
KrayZee -- :wob:
[2021-10-25. : 5:40 pm]
lil-Inferno -- :wob:
[2021-10-25. : 9:27 am]
Moose -- :wob:
[2021-10-24. : 12:54 pm]
Ultraviolet -- :wob:
[2021-10-22. : 8:31 pm]
O)FaRTy1billion[MM] -- :wob:
[2021-10-22. : 6:07 pm]
UndeadStar -- :wob:
[2021-10-22. : 12:00 pm]
Ultraviolet -- :wob:
Please log in to shout.


Members Online: Roy, Arkanis, KrayZee