architecture of unit tasking

Started by
3 comments, last by Norman Barrows 9 years, 6 months ago

I am making a strategy game so i need to command players units which can mine,build,construct and craft.

I have 2 classes designed yet:

Map - which keep the tasks in stack (each task type separately)

Unit - which need to do task

I need to handle not only accomplishing and assigning of tasks, but also canceling during progress (for example user decided that he dont want to build there, but the unit is on a half way to construction site already with mats, so the unit need to bring them back ). Can you guys give me any ideas or some simple class diagrams pls ?

Advertisement
what exactly is the problem? you could just switch the task from your Unit class to something alternative (e.g. idle) if it shouldn't continue with the current task. Is there much more to it?

i usually find it best to keep all orders info with the unit, IE what to build and where. it sounds like your map holds the what and where info (and perhaps by whom?), or am i just reading it wrong?.

in your example, orders to build would be replaced with orders to return resources to the storage depot, or to do nothing ( or some other default behavior), if the unit wasn't carrying any resources.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Well my current solution is that i am using struct task which have pointers on units. So when i cancel some task i can clearly see if the task is assignment. Now i have to figure out how to make AI to effectively pick and accomplish tasks.


Well my current solution is that i am using struct task which have pointers on units. So when i cancel some task i can clearly see if the task is assignment. Now i have to figure out how to make AI to effectively pick and accomplish tasks.

so the player queues up tasks, and the AI assigns appropriate units? and a task struct has all the "orders info": what to build, where to build, unit assigned etc. all that sounds fine.

tasks can be processed first come first serve, or on some priority basis (gather before build, etc). you'll probably want to use first come first served, so the player defines the order.

for assigning units, you'd probably use a best match search for closest available unit of the correct type.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement