Author Topic: Environment Interaction With Units  (Read 1393 times)

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Environment Interaction With Units
« on: 30 December 2012, 21:21:37 »
As part of an idea I was recently thinking of I wanted a way to have the environment affect units. Nothing as complicated as only building on special terrain types, though that is in the works, but mostly proximity effects.

I wanted some of the magical orders in my current game to have benefits if their buildings were near certain things. For instance pyromancers whose Motherhouse is by a volcano could gain some special benefits.

Currently my plan is to add a tags system to map objects. Then you can add various things to a unit based on its proximity to objects with the appropriate tag.

For instance some pseudo code:

if (building->isNear(object)) {
    applyBuffToUnitsMadeThere()
}

if (building->isNear(object)) {
    produceNewResourcesOnTimer()
}

The XML for the unit would be like:
<proximity>
<tag name="volcano">
<enhancement>
//fill in normal enhancement XML here
</enhancement>
</tag>
</proximity>

How useful would that kind of thing be to people?

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Environment Interaction With Units
« Reply #1 on: 31 December 2012, 02:26:48 »
While it could be useful, it feels a bit overcomplicated and the AI would need a lot of work if it was going to utilize such a feature. By overcomplicated, I refer to the hassel of finding a placement for units. And resources (such as trees) can't be used because workers automatically use nearby resources of the same type when harvesting. So it has merits, but I'm not sure if this feautre would be entirely useful.

A more practical use, I suppose, might be having environmental objects damage units, but that would be even more complicated, since we are limited to 10 different objects.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Environment Interaction With Units
« Reply #2 on: 31 December 2012, 03:41:20 »
While it could be useful, it feels a bit overcomplicated and the AI would need a lot of work if it was going to utilize such a feature. By overcomplicated, I refer to the hassel of finding a placement for units.
I don't understand. What hassle with placement?
And resources (such as trees) can't be used because workers automatically use nearby resources of the same type when harvesting. So it has merits, but I'm not sure if this feautre would be entirely useful.
Don't know what this means. Why couldn't you use trees? Especially since you can have trees that can't be harvested anyways, but even ignoring that.
A more practical use, I suppose, might be having environmental objects damage units, but that would be even more complicated, since we are limited to 10 different objects.
I fixed that for resources, its trivial to change it for other map objects also. Also that's totally possible in a variety of ways. Some are more performance efficient than others.

Don't worry about trivial engine limitations, such things are easy to fix. Making the AI able to deal with various things is not as hard as you might imagine. Its all in how you organize the AI's understanding of the world. Mandate's AI will be able to identify choke points on any map for instance and deal with varying unit sizes, that's much more difficult than allowing the AI to recognize where to build special buildings.

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Environment Interaction With Units
« Reply #3 on: 31 December 2012, 09:39:42 »
Okay I programmed in the ability to build structures on top of objects. It took me a bit to figure out the code and where I could and had to modify my copy of the isFreeCell code. It is almost fully functional, if you click too far to the bottom and/or right units place in a slightly iffy way so that they take up space of the nearby objects if there are any but that is actually semi common in most games.

This allows you to limit the placement of some buildings to the proper "foundation" object or objects. I was planning to work in the proximity code as well but the foundation stuff took too long cause of some errors with my windows install. I haven't decided if I'm going to sleep now, if not I can finish it in pretty short order. It just checks if the right object is nearby at build time. I thought about using foundations set next to the object but I want to be able to build them anywhere and just not get the benefits if its not right. Still a modder could use foundations adjacent to objects if they really wanted to as the code is currently written.

Coldfusionstorm

  • Golem
  • ******
  • Posts: 868
    • View Profile
Re: Environment Interaction With Units
« Reply #4 on: 31 December 2012, 10:57:56 »
This sounds very useful, I can imagine a few possibilities in my own game that can use these.

This can be used on resources too right?.
WiP Game developer.
I do danish translations.
"i break stuff"

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Re: Environment Interaction With Units
« Reply #5 on: 31 December 2012, 20:50:37 »
Yup works on any map object as far as I am aware. It clears the object off the map if you build on it, although that's not too hard to set to optional if you need to.

 

anything