• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help with JASS AI - Workers not harvesting lumber

Status
Not open for further replies.
Level 4
Joined
Apr 14, 2021
Messages
56
Hello, I am basically new to JASS scripting. I have recently made a very standard AI, and everything seems to be going great so far! But the problem with my AI is that when the workers are trained they harvest gold, not lumber as I want them to (not the starting workers, the newly trained ones). I have also created waves, and the workers go harvesting lumber only when the wave starts (till the end of the game). If any of you wonder what race the AI is, it's a High Elf race. I also haven't set the campaign elf workers, but edited the human peasant and made him look like a elf worker.
P.S. I don't know if this is a necessary information, but I don't have WaitForSignal() because I heard it doesn't need to be put and because it messes with the AI, it doesn't send out the waves when the command is there, wherever it is placed it still finds a way to mess with the AI. If you need any screenshots of the in-game AI behavior or JASS codes, feel free to ask.
 
Level 4
Joined
Apr 14, 2021
Messages
56
Alright, here you go.
 

Attachments

  • 1618430672078.png
    1618430672078.png
    80.2 KB · Views: 60
  • 1618430701223.png
    1618430701223.png
    60.8 KB · Views: 59
  • 1618430725871.png
    1618430725871.png
    58 KB · Views: 52
Ok, so you don't need to worry about Call WaitForSignal. It's a very useful function for delaying attack waves and stuff and not starting attack waves until you want them to.

Trying getting rid of the Clear Harvest Ai bit, the call HArvest wood and gold bits as well as the set campaign_gold_peons. All spare workers are automatically assigned to gold. all you need to do is set the campaign_wood_peons and that should work.
 
Level 4
Joined
Apr 14, 2021
Messages
56
Thanks for your response. I've already done that, but it didn't work, I tried it again right now and it still didn't work. Any other way?
 
Level 4
Joined
Apr 14, 2021
Messages
56
Could you perhaps be able to find the problem out from the in-game screenshots of the AI behavior?

I'm gonna repeat that call WaitForSignal() fixes the problem, but it doesn't start the attack waves. But when I put the command down or just remove it, everything works, except the 8 of them straight go mining gold. They only start harvesting lumber (till the end of the game) once the first wave is sent.
 
Last edited by a moderator:
Could you perhaps be able to find the problem out from the in-game screenshots of the AI behavior?
I wouldn't think so, the only really relevant things are the JASS code itself and maybe the object editor data in some cases. I'm really not sure what the issue could be. Why don't you try just copying that part of the code from one of Blizz's campaign AIs and then just editing it to suit your needs?
 
Level 4
Joined
Apr 14, 2021
Messages
56
I tried looking at Blizz's AIs and they are practically similar to mine, they also have call WaitForSignal(). Which leads me to believe that the AI needs to be controlled through triggers (specifically for harvesting and attacking). Here are a few screenshots on how I did it.
P.S. Blizz's AIs didn't harvest lumber when I ran the Fall of Silvermoon campaign and used cheat 'iseedeadpeople' to view the map and check how their AI behaves. The workers only harvested gold and the attack waves worked for them, despite having call WaitForSignal(). I'm pretty sure they could of had made their workers harvest lumber. And that makes me believe that it needs to be somehow controlled through triggers.
 

Attachments

  • 1618497044049.png
    1618497044049.png
    33.6 KB · Views: 30
  • 1618497059309.png
    1618497059309.png
    6 KB · Views: 33
Ehhh, yeah that's what WaitForSignal() does it prevents the code from running further (for AIs this is usually the attack waves) until sent a signal via triggers. However harvesting and attacks etc are all controlled via the AI.

This is so you can have the AI running with slow harvesting etc from the start of the map but the AI will not attack until you want it to i.e. after a intro cinematic finishes.

If you look at the Culling Human Mission 06 you'll see a much more complex use of AI command signals being used but that's kind of besides the point.
 
Level 4
Joined
Apr 14, 2021
Messages
56
Are you implying that I can basically have call WaitForSignal() there and call out waves? If so, how can I call out waves even if call WaitForSignal() is there? I put the command ahead of wave 1. Putting it below messes with the workers' harvesting priorities as I said.
 
Level 4
Joined
Apr 14, 2021
Messages
56
I just tested something, the triggers that I put 'A unit owned by Player 2 is attacked' and 'Send Player 2 the AI command' messed with the waves actually. I removed them and just put 'Send Player 2 the AI command'. I put call WaitForSignal() and it seems to be working. But the problem with harvesting priorities still stands. Could it possibly be because of the terrain or a bug? Though, I still believe that there needs to be a code put in JASS so that it works. Do you perhaps know of a campaign/map that uses the similar JASS script for AI(s) that I am? If so, can you please forward it to me so that I can check it out. Thanks in forward. :)
 
Level 4
Joined
Apr 14, 2021
Messages
56
And the workers do harvest lumber, but only after the first wave is sent at me. If it was a standard melee game, where they had starting resources 500 gold and 150 lumber, they'd build only a few structures until they run out of lumber then they'll stop and won't proceed to send workers to gather lumber. The game would be so broken.
 
If it's for a campaign you should trigger it so the AI doesn't need to harvest and gets given resources automatically. So for example a trigger for when the enemy player drops below 1000 gold add 1000 gold to their properties and the same for lumber.

As for why they don't start gathering lumber until after the first wave that is confusing. Try putting the set_lumber_peons in different parts of the script and see if that works.
 
Level 4
Joined
Apr 14, 2021
Messages
56
Precisely, yeah. Here are the screenshots.

Screenshots contain: workers harvesting gold & building, AI training defensive and attacking units, AI training more workers (there would be three extra harvesting gold if the one at the bottom wasn't building, but currently 2 extra at the gold mine), AI sending attacking units, workers going harvesting lumber once wave 1 is sent.

And that's basically it. When new workers are trained, they repeat the cycle of the first trained workers. They go harvest gold, after another wave is sent, they go harvesting lumber.
 

Attachments

  • 1618520884840.png
    1618520884840.png
    4.7 MB · Views: 36
  • 1618521031774.png
    1618521031774.png
    4.7 MB · Views: 30
  • 1618521627866.png
    1618521627866.png
    4.5 MB · Views: 26
  • 1618521673526.png
    1618521673526.png
    3.8 MB · Views: 28
  • 1618521752082.png
    1618521752082.png
    4.4 MB · Views: 29
Level 4
Joined
Apr 14, 2021
Messages
56
I'm not making a campaign, I'm trying to make it like a melee ai, just with campaign units. But I'm well aware it'd be better if it was for a campaign, or already pre-set buildings.
 
Status
Not open for further replies.
Top