Author Topic: Walls?  (Read 3174 times)

dannylee

  • Guest
Walls?
« on: 15 October 2009, 23:26:06 »
Hi guys, I have an idea about walls, I think walls would be great, so you can seal of an area to protect you more. Here is an idea for walls for different factions:
Tech: Wall should look like in the middle ages, like rock and stone
Magic: Wall should look like a hedge coming out of the ground, or like trees that form the wall (but still can be destroyed)
Invaders: Walls should look like a fort wall, made out of wood
Military: should have a barbed wire fence
persians: clay walls
norsemen: walls like the tech faction
indian: wall made out of boulders
romans: wall should look like the invaders, made out of wood

what do you think about it?
please let me know
Danny

Mark

  • Guest
Re: Walls?
« Reply #1 on: 16 October 2009, 02:23:40 »
Well, this should probably go in mods, but you have good ideas. 


daniel.santos

  • Guest
Re: Walls?
« Reply #2 on: 16 October 2009, 07:56:56 »
I like your concepts.  In fact, we started implementing walls in Four Path Magitech and GAE, but it's never been finished.  Well, that's actually not true, you can build walls in FPM's tech faction now, but the AI doesn't understand them.  In fact, the AI will build one section of a wall somewhere, as if it were a regular building, when it plays FPM tech! :)  Since codemonger.org is down right now and I can't just link the files, so here's the important parts:

Code: [Select]
<unit>
    <parameters>
        <multi-build value="true"/>
        <properties>
            <wall/>
        </properties>
    </parameters>
</unit>

And here's the entire contents of four_path_magitech/factions/tech/units/wall/wall.xml for reference.
Code: [Select]
<unit>
    <parameters>
        <size value="2"/>
        <height value="4"/>
        <max-hp value="1500" regeneration="0"/>
        <max-ep value="0"/>
        <armor value="0"/>
        <armor-type value="stone"/>
        <sight value="10"/>
        <time value="20"/>
        <multi-build value="true"/>
        <multi-selection value="false"/>
        <cellmap value="false"/>
        <levels/>
        <fields>
            <field value="land"/>
        </fields>
        <properties>
            <wall/>
        </properties>
        <light enabled="false"/>
        <unit-requirements/>
        <upgrade-requirements/>
        <resource-requirements>
            <resource name="stone" amount="25"/>
            <resource name="wood" amount="10"/>
        </resource-requirements>
        <resources-stored/>
        <image path="../../../../../magitech/factions/tech/units/pig/images/pig.bmp"/>
        <image-cancel path="../../../../../magitech/factions/tech/units/archer/images/tech_cancel.bmp"/>
        <meeting-point value="false"/>
        <selection-sounds enabled="true">
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_select1.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_select2.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_select3.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_select4.wav"/>
        </selection-sounds>
        <command-sounds enabled="true">
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_ack1.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_ack2.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_ack3.wav"/>
            <sound path="../../../../../magitech/factions/tech/units/pig/sounds/pig_ack4.wav"/>
        </command-sounds>
    </parameters>

    <skills>
        <skill>
            <type value="stop"/>
            <name value="stop_skill"/>
            <ep-cost value="0"/>
            <speed value="1000"/>
            <anim-speed value="55"/>
            <animation path="models/wall.g3d"/>
            <sound enabled="false"/>
        </skill>

        <skill>
            <type value="be_built" />
            <name value="be_built_skill"/>
            <ep-cost value="0" />
            <speed value="300" />
            <anim-speed value="20" />
            <animation path="models/wall_construction.g3d"/>
            <sound enabled="false" />
        </skill>

        <skill>
            <type value="die"/>
            <name value="die_skill"/>
            <ep-cost value="0"/>
            <speed value="90"/>
            <anim-speed value="90"/>
            <animation path="models/wall_destruction.g3d"/>
            <sound enabled="true" start-time="0">
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall1.wav"/>
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall2.wav"/>
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall3.wav"/>
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall4.wav"/>
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall5.wav"/>
                <sound-file path="../../../../../magitech/factions/tech/units/barracks/sounds/tech_building_fall6.wav"/>
            </sound>
            <fade value="false"/>
        </skill>
    </skills>

    <commands/>

And I'm glad you brought this up, because Silnarm has been Mr Pathfinder lately, and that's the portion of the AI that a lot of this has to go into.  The AI should essentially ignore walls, unless they are in the way -- that's the easy description.  The technical definition is probably something more like this:
  • The AI would very much like to beat you up.  If it knows where your buildings are, and it has a path to them, it should just ignore any walls it encounters (and go around them).
  • If it knows where your buildings are, but can't path to them without going through a wall, then it should try to destroy a portion of the wall to get to you.
  • If it doesn't know where your buildings are yet, then attacking any walls it finds might be a good start.

When attacking your walls, the AI should probably choose a portion that appears least defended.  Then again, it should also go for the weakest portion of wall.  If there's an area of wall that's heavily defended, but nearly destroyed, the AI should probably just go for it.  Otherwise, it should choose a less defended portion of the wall to breach.  I'm sure there's millions of other things that can be done to optimize this, but this much would probably be a good start at getting the AI to work properly with walls.

One final consideration is the size of the breach.  If it wants to attack with units larger than a 1x1, it should create a breach that's 2x2 in size.  But now that gets into more details, because that should be different from one faction type to the next (and we're supposed to be designing this engine to work optimally with various mods).  Thus, the AI has to determine which units it's attacking with and their max size to know how big of a breach it needs.
« Last Edit: 16 October 2009, 07:58:36 by daniel.santos »

Mark

  • Guest
Re: Walls?
« Reply #3 on: 17 October 2009, 03:17:59 »
Would you be able to mount units on walls?  That seems to be more common nowadays, and it is also very cool.  But I would completely understand why you might decline.  That is probably VERY complex. 

One final consideration is the size of the breach.  If it wants to attack with units larger than a 1x1, it should create a breach that's 2x2 in size.  But now that gets into more details, because that should be different from one faction type to the next (and we're supposed to be designing this engine to work optimally with various mods).  Thus, the AI has to determine which units it's attacking with and their max size to know how big of a breach it needs.
Please don't forget that right now the AI attacks all buildings, so you must change the AI in order for the AI to be competent in that way.  You definitely don't want an AI held up on an irrelevant section of wall while enemy archers pick of their soldiers. 

I have an idea for how the AI would build walls.  You mention that they are built randomly, well here is a crude solution: 

Some things you must understand first:
1.  The AI must have a gate to go through, which would morph between closed and shut. 
2.  If units stationed on walls is implemented, there must be a stairwell that would allow access to the wall's ramparts, behind the crenellations.

Alright.  Now, each wall would have to be built far from the town right?  So each building, say one with a size of x (in this case a building the size 3), must be a y distance from the wall to allow expansion.  So an equation for the AI to decide how far away to build the wall from the town, would be y=2x+6.  The 2x is how far away I think the wall should be built.  And the y-intercept is how far away a wall must be no matter what size, because you can't have a 1 tile building with a wall three tiles away!  The 6 would prevent this.  So each town (concentration of buildings) would have an imaginary green footprint much larger than the towns size.  And at the edge of this would go the walls.  In this case, the 3-tile building would have a wall 12 tiles away.  I think this is reasonable, but walls would not do well on a small map.  I know that this is complicated and hard to understand, but I can't explain it better.

dannylee

  • Guest
Re: Walls?
« Reply #4 on: 17 October 2009, 05:07:28 »
cool, where can i download the wall files, or aren't they finished yet?

dannylee

  • Guest
Re: Walls?
« Reply #5 on: 18 October 2009, 21:20:17 »
when are the walls made? are there any thoughts of making them? (i would do it my self, its just i am an idiot in using blender and c++)

Mark

  • Guest
Re: Walls?
« Reply #6 on: 19 October 2009, 00:19:59 »
I don't think they actually made the models, but they [daniel.santos and the other coders] might have worked on some C++ stuff.  I don't know where to find it, and they may still be working on releasing a good version...

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Walls?
« Reply #7 on: 19 October 2009, 11:09:33 »
Would you be able to mount units on walls?  That seems to be more common nowadays, and it is also very cool.  But I would completely understand why you might decline.  That is probably VERY complex. 

There is a 'concrete plan' for implementing this, but I keep getting side-tracked.  However, the most recent digression has provided a rather nifty tool for AI, and I now also have a concrete plan for how an AI will decide where to build walls, using my new best friend Dijkstra search. Good things will come to those who wait, unfortunately you might have to wait a little while yet... sorry.
Glest Advanced Engine - Code Monkey

Timeline | Downloads

daniel.santos

  • Guest
Re: Walls?
« Reply #8 on: 19 October 2009, 18:52:00 »
Sorry for the slow response.

dannylee,
glest.codemonger.org is the best place to download it, but it's down at the moment. :(  Send me a private message with your email address and I'll email them to you.

Mark,
Yea, I addressed the AI encountering enemy walls in my last post (scroll up).  I didn't address how the AI should actually build walls, but the fact that they will have to do better is a given.  I'm going to let Silnarm play with this for now, he seems to have a lot of cool stuff going on.  But your proposed formula wont work entirely as-is -- some buildings are defensive structures that you want either along the wall or directly behind it (e.g., archer towers).  While the AI should plan walls with room to grow (if the base isn't already full-grown by the time it starts building walls), it would also be nice if it was smart enough to build outside of the walls, build new enclosing walls and then tear down the old ones (or just have inner and outer walls & gates) -- but that's cake.

As far as visuals are concerned, there are some minor issues with making walls look pretty.  Each section of the wall will potentially have a different altitude.  So to make them line up pretty, we'll have to morph them to join neatly with adjacent sections of wall.

Mark

  • Guest
Re: Walls?
« Reply #9 on: 20 October 2009, 01:59:57 »
Sorry for the slow response.

dannylee,
glest.codemonger.org is the best place to download it, but it's down at the moment. :(  Send me a private message with your email address and I'll email them to you.

Mark,
Yea, I addressed the AI encountering enemy walls in my last post (scroll up).  I didn't address how the AI should actually build walls, but the fact that they will have to do better is a given.  I'm going to let Silnarm play with this for now, he seems to have a lot of cool stuff going on.  But your proposed formula wont work entirely as-is -- some buildings are defensive structures that you want either along the wall or directly behind it (e.g., archer towers).  While the AI should plan walls with room to grow (if the base isn't already full-grown by the time it starts building walls), it would also be nice if it was smart enough to build outside of the walls, build new enclosing walls and then tear down the old ones (or just have inner and outer walls & gates) -- but that's cake.

As far as visuals are concerned, there are some minor issues with making walls look pretty.  Each section of the wall will potentially have a different altitude.  So to make them line up pretty, we'll have to morph them to join neatly with adjacent sections of wall.

Thank you for responding and yes, I did notice that issue.  I understand that you guys probably know how to do it, so I will not say you are doing it wrong.  But I must say, i like my idea because the CPU has to build the walls farther away, but there are problems like the AI not placing towers well, not placing certain buildings far from danger, like the castle, and so on.  I really don't know what to do, but I bet you guys do.

dannylee

  • Guest
Re: Walls?
« Reply #10 on: 20 October 2009, 06:45:33 »
Wow, looks like I started a hot topic, well I am starting to get into modeling and animating factions, and I will try to make a wall my self, and when it's good I upload it and you guys can do the advanced stuff such as open and closing, an AI building it properly.
Maybe we can even change the AI to be smarter! Just like other real time strategy games such as world of Warcraft, age of empire, empire earth and so on

daniel.santos

  • Guest
Re: Walls?
« Reply #11 on: 21 October 2009, 18:48:42 »
But I must say, i like my idea because the CPU has to build the walls farther away...

Oh, there's nothing flawed about that idea in and of it's self.  It was just your formula that I didn't think would necessarily work well. But I think you are correct, the AI should generally make walls in a way that accounts for future development.  It's also not a bad idea to keep important (and especially vulnerable) structures a fair distance away from walls so an attacker can't easily destroy them with ranged weapons.  But other things to consider for the AI:
  • Utilizing existing non-passable barriers (trees, rocks, etc.) will reduce the total amount of wall that needs to be built, saving both time and resources.  This may mean to expanding or contracting what would otherwise be an ideal border in certain parts of the perimeter.
  • If you have workers harvesting beyond the "ideal range", you want them protected.  It also becomes a consideration rather to encapsulate their work area in your borders or just protect your base 1st and then try to build a secondary fortification around the workers and resources.
  • In the future, we may want to implement mechanism whereby the altitude difference of two opposing units causes "higher ground" bonus.  For example, the attacker on higher ground can receive increased range and damage and the defender decreased armor.  This would then need to be a consideration in the AI's choice of where to build walls.


John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Walls?
« Reply #12 on: 21 October 2009, 19:33:06 »
It's also not a bad idea to keep important (and especially vulnerable) structures a fair distance away from walls so an attacker can't easily destroy them with ranged weapons.
I wonder, should ranged units be able to shoot past the walls?  Maybe we could restrict it based on the projectile type, so parabolic attacks would work, because they'd arc over the walls, but linear attacks would not, except in the case of flying units.

daniel.santos

  • Guest
Re: Walls?
« Reply #13 on: 21 October 2009, 20:19:40 »
Hmm, I hadn't thought about this enough because I've been re-working the entire system that does this.  But you are right.  At current, projectiles only stop when they hit the ground.  I guess this is also a question of visibility: should an archer even be able to shoot a unit on the other side of the wall if s/he can't see the target?  Crap, there's a lot to consider in this.

Usually, you would want to cheat your projectiles so that they phase right through friendly units (otherwise, you have to deal with a lot of aiming details) but impact the 1st object it encounters of types: ground, world object (tree, rock, etc), enemy unit (and maybe water).  I can see a number of ways to deal with this, but it addresses the core way the Glest/GAE does targeting & attacks.  Probably, we'll want to set a flag for attacks as to rather or not they require line of sight.  Then, we have to check to see if they have line of sight before we allow the attack.  Finally, while the attack projectile is moving through the world, we need to check for collisions that should kill it.

The classes AttackParticleSystem and ProjectileParticleSystem (from the Shared::Graphics namespace) are going away.  See the Refactoring "Game Objects" thread for more details on this.  If you look at that diagram, they will be replaced with the "Projectile" class, which will basically be the same as a Collidable object, but with a will encapsulate the types of collision rules we currently fulfill with AttackParticleSystem and ProjectileParticleSystem.  The point here is the separate the "particle system" (which is the visuals) from the attack logic.

However, this is a fairly large area that I'm not ready to delve into at the moment.  I want to finish up a lot of other things, so we'll probably just leave it as-is for now, but flag it as a TODO.

Mark

  • Guest
Re: Walls?
« Reply #14 on: 22 October 2009, 01:55:34 »
I wonder, should ranged units be able to shoot past the walls?  Maybe we could restrict it based on the projectile type, so parabolic attacks would work, because they'd arc over the walls, but linear attacks would not, except in the case of flying units.
Maybe a simple physics system could be implemented: you know, no two objects can occupy the same space.  This is what the Total War series uses, but I wonder, how would you stop an archmage from killing all in front of it?  This is not a good idea to me, but I can think of no others.

modman

  • Guest
Re: Walls?
« Reply #15 on: 29 October 2009, 23:15:48 »
Maybe when you build walls, you can "cash them in" for resources, and so in this way the AI and the humans would be helped.  But I think the most efficiant way for the AI to construct a town is to build resource collectors near resources and the main building (like the Castle in Tech) more centralized because they will build workers which need to build buildings everywhere.

Maybe walls would be more of a "block just enough path" kind of thing rather than a thing which encircles the entire base.  This way, there is no question as to what it the most efficient placement.  This means that walls would be placed at the "mouth" of the road system on a map, where much enemy traffic will be.  The more enemy traffic there is, the more effective the wall can be at blocking that enemy.

Did I mention the three types of wall pieces there should be?  Basically, normal wall, towers which attack, and gates.  Stairs would be a fourth if units can walk on the walls, but the towers can double for this function.

daniel.santos

  • Guest
Re: Walls?
« Reply #16 on: 9 November 2009, 09:32:23 »
Yea, good point on towers doubling as stairs.  In general, walls aren't of much use if you don't have a good way to defend them.  I don't like the idea of being able to "cash in walls" because once you build them, they are pretty static.  If there's another way in, then walls are generally useless -- they must surround the entire camp to be of much good, unless the alternate path gives you a sufficient amount of additional danger.  Defensive structures (including walls) should be far stronger than any other structures or units.  The cost of walls should be relative to their defensive strength.  And yes, gates will generally be necessary for walls to be of much use, although a passage lined with attacking defensive structures can prove effective, it shouldn't be nearly as effective as complete blockage.