• 🏆 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!

[Trigger] Custom Order Queue

Status
Not open for further replies.
Level 11
Joined
Nov 15, 2007
Messages
781
I've hit a snag in an order queue system I'm working on. It's a small part of a bigger system, but it's a very important part.

Basically, your units are owned by a computer-controlled ally. Some units, particularly worker units, follow certain orders in a queue. One of the primary orders your workers will be issued is digging tunnels. I've got the basics of it down, and my current implementation works like this:

1. The map is full of neutral unit obstacles. When a player selects a unit that can be dug through, that unit is added to a group. If the unit is selected again, it will be removed from the group.
2. Idle workers will automatically attack the first unit added to the group (or "dig" it, if you will) until it dies.
3. Once the first unit is killed, it checks to see if there are any more units in the group. If there aren't, the workers return to their idle state. If there are, the workers attack a random unit in the group.

It works on a rudimentary level, but to optimize it and make it passable I need help with the following:

1. Proximity check. When you issue a dig order, it should assign the closest workers to the task. Similarly when the target dies, the next target should be the closest one in the queue.
2. Impossible orders check. If you queue a unit to dig through, but the unit cannot be reached by your workers for some reason, the workers should return to idle if there are no reachable targets in the queue.
3. Scaling workers to available surface area. Every possible target is about 3 worker-lengths on every side - thus, if you queue a target that is surrounded on 3 sides, it should at most send 3 workers to dig out, as any additional workers would just be blocked by the first 3 workers' collision. This system needs to scale with available surface area rather than amount of queued targets. If you queue up 300 targets, but they're all in a single narrow line, it would still only take a maximum of 3 workers - but if you queue up a 2x2 grid, it would take up to 24, because there are 4 targets with 2 surfaces available each.


I would greatly appreciate assistance with #1 and #2. I'm not sure if #3 is even possible, but if anyone can help with that I'd be very grateful. It would be nice if the solution was primarily GUI so that it's easy for me to understand and edit, but it's not a requirement.

And yes the map is based heavily on Dungeon Keeper.
 
Status
Not open for further replies.
Top