1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. Vote for the best entries in the 13th Music Contest Poll.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Stone Gathering Fix

Discussion in 'Triggers & Scripts' started by UmbraUnda, Feb 20, 2017.

  1. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Nope - it's the lumber mill for lumber. Stone mill for stone.

    Could we make a unique ability for returning stone at least?
     
  2. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    I always selected the female workers and wondered which building I can return stones to.

    Yes that would be possible. I am reworking the drop-off at the moment. Right now you can only return stones, if you have as much stones harvested as possible and are nearby the drop-off building. I will make it so, that ressources are returned, if the worker has >0 stones, is close to drop-off building b and was ordered smart at unit b.

    The return ability would order the unit to use smart on the closest drop-off building. There is a big disadvantage which cannot be solved. You cannot really determine the closest drop-off building (including pathability of terrain). A drop-off building could be chosen, which has a very small linear distance, but is very far away due to unpathable terrain.

    Maybe it is even possible to put the standard return ressources ability in a disabled spell book and use the custom one for both.
     
  3. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    This is a raw exmaple. If you interested to FULLY REPLACE your current system then tell me.
     

    Attached Files:

  4. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Why not both workers?

    Awesome mate. Good idea, makes sense - as long as it works.

    Oh, dang. Can you make it any of stonemills (1-4)? Wait are you saying it won't work? Or that it'll work however its not the best way to do it?

    Hmm, whatever works honestly... If a spellbook is the best or most stable way to get it done then let's do that.

    Thanks for the reply.

    Your system looks good overall however there are some instabilities - for instance sometimes the peasant returns with 18 gold, other times 19.
    I'm not sure you took into account everything I that the current stone gathering system already uses...
    So in short, thanks but no thanks. I just want to improve the system I already have.
     
  5. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    I fixed the return resources (only return resources when directly ordered to return, not when nearby and maximum amount of stone harvested).
    Works for any stonemill.
    It will work, but not the best way. There is no function to get the closest object including pathing restrictions in warcraft.
    Here an example (I am using lumber mill instead of stones here)
    upload_2017-3-25_22-15-14.png
    This peasant would move to the lumber mill on the other side of the cliffs, because the linear distance is smaller, even though the lumber mill on the right side is closer.
    The warcraft ability return resources has a hardcoded method to find the closest lumber mill including pathability.
    As I said you cannot change it and you must accept it as it is. In most cases you won't recognize it as most of the times the closest lumber mill has also the smallest linear distance.
    You could have the player decide which lumber mill should be used as drop-off using a new ability, but that would just make it too complicated.

    Edit: here is the map. I also added the return rocks ability. If you want to copy my rock gathering stuff into your map you need to copy the trigger folder RockGathering and create the ability Return Rocks and put it in the triggers where needed (TakeDamageStone,CheckRockDropoff,ForceReturn).
     

    Attached Files:

    Last edited: Mar 25, 2017
  6. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Thanks a bunch mate! That was quick , just in time - I'm about to release 0.2a !

    O0o0o no worries mate, I don't have cliffs in my map and haven't put in any pathing blockers yet.
    Hopefully you can come up with some way around that eventually. For now, it's fine.

    I'll go implement this into my map now and let you know how it goes later.

    Also were you able to figure anything out about the glitched workers if they harvest without a stonemill?
    I was thinking along the lines : condition that requires a stonemill, otherwise actions for harvesting are canceled.
     
  7. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    I think there is just no way to find the closest building including pathability, since there is no native function to do so. Making such a system yourself is incredibly hard and on such a big map absolutely impossible.
    Another option if you really care that much about it, is to have the return rock ability target a unit instead of no target. Using it will store the target(stone mill) to the unit and the unit will always return stone to this mill. When the mill gets killed the unit will go back to searching the closest mill. This way the player could decide where the worker should return stones.
    You could also add the possibility to target self (the worker) to manually go back to searching the closest mill.

    No I did not do anything about it. I guess the best way would be to use the event "is attacked" and stop the attack when it is about to start.

    Another thing I would like to note is, that workers can harvest stones and lumber at the same time (e.g. harvest lumber->harvest stone->return stones->return lumber).
    I don't know if there is an easy method to remove the carried resources from a worker.
     
  8. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    IT WORKS!! HA-HA-HA, IT WOOORKS! THE WORKERS WOULDN'T STOP UNTIL ALL ROCKS AROUND WOULD DESTROYED.
    I ALSO ADDED THE SYSTEM WHICH DOESN'T ALLOW YOU TO STORE COLLECTED STONE ON UNFINISHED BUILDING.
    P.S. I COMPELTELY DELETED THE PREVIOUS SYSTEM.
    PSS THIS SYSTEM COUNTS BOTH STONEMILL AND LONG HALL.
    PSSS IF YOU ORDER THE WORKER WITH FULL STONE BAG TO COLLECT STONE AGAIN IT MAY GO TO THE STONE MILL (LONG HALL) INSTEAD.
     

    Attached Files:

    Last edited: Mar 25, 2017
  9. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Thanks again for the help. Hmm, more things to work on in the future I suppose. This is fine for now though.

    O snap... lemme test and I'll let you know how it goes.

    EDIT: I'm not sure what happened however its broken and unstable.
    When I clicked for workers to harvest, they kept returning after 1 strike.
    I tried rearranging distance and far away the workers harvest all the way to 10 however once it was returned they would glitch out moving and stopping repeatedly... I tried clicking again to harvest however the worker would not harvest, only walked toward the stone. This may require additional testing to pinpoint whats causing the instabilities.

    I looked over the trigger and it looks great, even saved some space too.
    Hopefully its a small fix mate - I want to see this trigger working 100%.
     
    Last edited: Mar 26, 2017
  10. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Are you sure you played a wrong version? I tested again and it doesn't glitch. Anyway here is another one
     

    Attached Files:

    Last edited: Mar 26, 2017
  11. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hmm - still having the same issues. Works however unstable... Must be something with the range check... or my game @_@ ?
     
  12. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Can you post a screenshot to see worker's behavior? or video? Me and deepstrasz checked it and it works, but the workers are choosing the recently building instead of the closest. But they don't run to store resources after 1 strike.
     
  13. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Here is a new variant. Sorry if i name it as WorldEdit TestMap because my WC doesn't want to detect the map if i use first name.
     
  14. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    I fixed it now. Workers can no longer harvest stones, if they already carry as much as they can. If no Stone Mill can be found the worker will just stop (same as with normal resources in warcraft). If you order a worker to harvest a stone even though he already carries as much as he can, he will still move towards the stone and when he reaches it he will search for a drop-off (this is also exactly how it is in warcraft with lumber).

    Also I changed that only finished Stone Mills serve as drop-offs.

    Tell me if you need any changes.
     

    Attached Files:

  15. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Awesome mate - thanks again for putting in the work. I really appreciate it. I'm about to hit the gym however later tonight I'll let you know how testing goes.

    o0o0o snap. Thanks Jampion, with this new system its pretty much done! Only thing left now is to make it so workers can't harvest stone and lumber (and carries both of the resources at the same time) + Fruit Forest said there were some leaks. Awesome work, I'll give you both more rep soon - I'll test it out soon when I get back from the gym.
     
  16. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    I don't know if there is an easy possibility to remove the carried resources. There are definitely methods, but they would have side effects. I pretty much only improved the functionality of the existing system. I have not removed the leaks that were already there.
    I will investigate on removing carried resources.

    Edit: removing and adding the harvest ability seems to work.

    Edit2: i can't find a way to detect when a worker starts harvesting lumber
    there is no destructible is attacked event, the ability (harvest lumber) and orders are given before and are not directly connected to hitting the tree.
    Only solution I see at the moment is triggering lumber similar to stone harvesting.
     
    Last edited: Mar 26, 2017
  17. Fruit Forest

    Fruit Forest

    Joined:
    May 16, 2016
    Messages:
    733
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Well i recomend you two variants:
    1. Make all trees to be a units not destructible. (idk can the system handle it because units take more memory)
    2. Make spell based on eat tree (resurrect trees isn't a problem, but again have to script all AI)
    These both ways can detect number of harvested tree.
     
  18. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    So we could copy the stone harvesting system and replace attacking with casting eat tree. I would definitely go with number 2 here, as over 9000 units just for trees would be too much.
     
  19. UmbraUnda

    UmbraUnda

    Joined:
    Mar 31, 2016
    Messages:
    639
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Great ideas. Or maybe a true and false condition/comparison could work?

    Example: Worker carrying stone - True. Worker goes to harvest lumber (still carrying stone) - unable to use gather on trees. Or (like in AoE II) drops the stone carried as it uses gather on trees. Then again vice versa for the other resource. Might not work but its an idea.

    Also does the current system in 0.2a have any leaks?
     
  20. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    The problem is that we don't know if a unit has lumber. Because of this we need to trigger lumber gathering as well.
    If you used my system, yes.

    If we are really going to trigger lumber harvesting as well, I will first rewrite the stone gathering in JASS and then use the same system for lumber.