FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Conditional blocking (only some units)  (Read 1128 times)

conan

  • Newbie
  • Posts: 17
    • View Profile
Conditional blocking (only some units)
« on: January 20, 2015, 08:01:27 pm »

Hi guys,

How would you implement the following: I have a map with land and sea. I have land units that cannot go to water cells. However, I have "amphibious" units that can also go on the water.

If I set the cells as blocking, then none of the units can go on the water. How can I make this blocking only for ground units? Can I somehow use the "cost" property of the cells? I'm not using this property at all by the way. I don't even know what it does. I guess it's some movement cost modifier but that's just my intuition.

* Also, keep in mind that I still want units not to step on each other so I can't just put different types of units on different layers. Also, there are other harder blocks as cliffs and hills that no unit can go through.

Cheers!
Logged

helios

  • Developer
  • Jr. Member
  • *
  • Posts: 61
    • View Profile
Re: Conditional blocking (only some units)
« Reply #1 on: January 21, 2015, 11:33:54 am »

Here the best solution would be the area stuff. It can be used as a sort of filter for pathfinding.
In your example you need two different area ids like land and water.
The xml code for the ground objects would look like:
Code: [Select]
<object id="water1" namespace="grassland_tileset" blocking="0" static="1" area_id="water">
<object id="ground1" namespace="grassland_tileset" blocking="0" static="1" area_id="land">

For the units:
Code: [Select]
<object id="land_unit" namespace="grassland_tileset" blocking="1" static="0">
   <walkable_area id="land"/>
   ...
   ...
<object id="amphibious_unit" namespace="grassland_tileset" blocking="1" static="0">
   <walkable_area id="water"/>
   <walkable_area id="land"/>
   ...
   ...

Cliffs and hills can still be set to blocking like the units or buildings.
I hope that helps :)

With the cost property it's possible to make movement on cells cheaper or more expensive. So if your ground have different costs the units will try to move on the cheapest terrain, as example your map could have land with normal cost, swamp with 2x cost and streets with 0.5x. So the units would prefer the streets but would also use both other terrains.
The cell speed is similar but the change concerns only the real movement speed.
Logged

conan

  • Newbie
  • Posts: 17
    • View Profile
Re: Conditional blocking (only some units)
« Reply #2 on: January 21, 2015, 11:44:03 am »

Thanks! Will implement it ASAP.
Logged