• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[AI] Choosing different path when near area

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I'm making this map where the computer takes a random unit out of a group and tries to get him to a certain point without being spotted by a watchtower. I want a AI script (at least I think I need AI for this) that causes the unit to have (let's say) 25% chance to choose another path to his destination point when he's about to get close to a watchtower.

Can anyone help me getting this done, because I've never done anything with JASS nor AI. Or should I make a post at Project Recruitment asking for someone to create the AI for me?
 
Level 24
Joined
May 9, 2007
Messages
3,563
When a unit enters region generate random #.

If 1-3 then advance to the next region in a specific array, which is preset.

If 3-6 then advance to another set of region arrays.

and if 6-9 then advance to the third set.

btw, use .x continuiing or more exact values.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I hardly use arrays. I only know what they do in a couple of cases, so correct me if I understand you wrong.

You say that I should make a region at points where I want the unit to make with paths through and give them a array. Then when the unit enters a region, it has 33% chance to go to the region with array 1, 33% for region with array 2 and 33% for region with array 3. If that's correct, then how can I set those arrays right in this case? And with the .x continuing, do you mean the Event 'Every .x seconds of the game'?
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Yea that's the point. I have more then 1 line. I've attached a Paint picture, giving you a view of the rough plan. The red are the paths he can walk, and the blue parts are where the regions are. The plan would be that there would be a certain change to go to 1 (adjacent) region when entering any of those regions. Do I manually have to set whether or not they can move to a region and how big the chance is, or is there a way to do that faster, easier and/or more understandable for outsiders reading the trigger? And how do I use the arrays in this case?
 

Attachments

  • Part 2 idea.jpg
    Part 2 idea.jpg
    295.6 KB · Views: 105
Level 18
Joined
Aug 23, 2008
Messages
2,319
Ok, if that is the best solution in your opinion, I'll take your word for that. Thanks a lot for your time and effort :wink:

+rep



BUMP

I've entered it, and I still have 1 little question. I've got a total of 174 'crosspoints' (the red stuff on the image). That means there are going to be 174 triggers just to make a unit go to a certain point and manually giving a chance to go to a adjacent region from each crosspoint. On top of that, I got to make a massive crowd in groups, that mark the paths (so that will probably a few thousand), and I got a few hundred other units crawling the same paths (to prevent a enemy unit being spotted on the eye instead by a watchtower). Could that cause major lag, leaks or file size by any chance?
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
Yes, I've read a few thread about leaks and leak preventing, but when I apply it, it gives me an error for each 'destroy' when I open it with WE, and the game can't be started until those commands are disabled or removed. So I think I better ask someone in Project Recruitment to make everything leak-proof when the maps are finished.

So this would only cause leaks (if they're not destroyed), and no obvious large file size or slow loading/playing?
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
But there are a few thousand units placed. Most are just standing villagers, but there are also a few hundred walking the paths. Would that cause the map to run laggy, require high computer specs or cause massive file size?

And if so, how can I reduce that, but still keep the terrain lay-out the same?
 
Level 8
Joined
Mar 23, 2007
Messages
302
Solutions;

Triggers: u could convert it to JASS, and fixing leaks there more efficient.

Mass Units: u could make them bigger and remove some
u could instead of a unit use a decoration thing (grass, laterns, etc...) then replacing the model with another one (mb this would reduce map size)
u could make PIC with screenshots and then edit them in PS, inportimg this Pics as flat images that look like people from top.

Mapsize (max 4 mb or u cant host it bnet) doesn't have anything to do with lag, it only inceases the DL time of the map (it becomes harder to share --> less public attraction).

Lag is demitert by the amount of things going on (visible and invisible, but the visible take more RAMusage). Not removing leaking things will cause your mape to be unplayable after some time.

greets equal
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Aaaaaah, he said the JASS word! My poor eyes are burning! (Sorry, but I've never used JASS, and probably never will unless I need small JASS inserts in my GUI triggers. Way too time-taking for me)

I've been also thinking about making the units a bit bigger, but they should still look like regular size units, so you don't get the idea that it's just to fill empty places in the map. They have a porpose of marking paths :wink:
The decoration thing will without a doubt be inserted. It gives a pleasure to the eye and has good purpose, so thanks for the idea there.
The screenshot idea won't be very nice. There will be camera's for a opening cinematic that follow the paths, so a flat image or a wall of units with a flat image behind it isn't really a sight worth the effort.

It's not the map size causng lag I fear of. I just want a decent sized map so people on The Hive Workshop can download easy and doesn't take long to load.

For the lag: I got a few hundred villagers walking the paths all at thesame time with 1 massive trigger spammed with If/Then/Else commands (1 for each crosspoint, giving chances to each region they can walk to next, manually entered), and a few other minor/decent sized triggers running at the same time. Having my eye on the few hundred villagers all using the same trigger over and over again, I would like to know if that would cause lag.

To give you an idea of what kind of trigger that one is, this is an example of what is entered for all 174 Crosspoint regions:
  • Events
    • A unit enters Crosspoint1
  • Conditions
    • Triggering Unit is owned by Player 3 (Teal)
  • Actions
    • If/Then/Else
      • If (All conditions are true)
        • RANDOM is Less then 20
      • Then
        • Order Triggering Unit to move to random place in Crosspoint2
      • Else
        • Do nothing
    • If/Then/Else
      • If (All conditions are true)
        • RANDOM is Greater then or equal to 20
        • RANDOM is Less then 35
      • Then
        • Order Triggering Unit to move to random place in Crosspoint3
      • Else
        • Do nothing
    • If/Then/Else
      • If (All conditions are true)
        • RANDOM is Greater then or equal to 35
        • RANDOM is Less then 70
      • Then
        • Order Triggering Unit to move to random place in Crosspoint4
      • Else
        • Do nothing
    • If/Then/Else
      • If (All conditions are true)
        • RANDOM is Greater then or equal to 70
      • Then
        • Order Triggering Unit to move to random place in Crosspoint5
      • Else
        • Do nothing
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
I can't test until I've bored the spine out my own back from making all 174 of such triggers, created all paths and placed all units that are supposed to crawl, so that could take a while :xxd:

Thanks for the info. That'll sure come in handy.


Problem solved!
 
Status
Not open for further replies.
Top