Sign in to follow this  
Followers 0
Mythos_Ruler

Stances

61 posts in this topic

STANCES

Stances are purely for behavioral purposes. Formations are for altering stats. Some Formations come with default Stances.

Click Here for the Stances Trac Ticket.

Stances and their Behaviors

Violent or Impetuous

OOaVh.png

Behavior: Will attack any enemy unit that wanders into vision range. Will relentlessly pursue retreating enemy units into the Shroud of Darkness for a short distance at a Run (depending upon stamina). Units in this stance tend to not hold their formation.

Aggressive or Eager

1sXVh.png

Behavior: Will attack any enemy unit that wanders into vision range. Will not pursue enemy units out of vision range.

Defensive or Reluctant

6E3Ig.png

Behavior: "Default" stance. Will attack enemy units who come within half vision range distance. Will pursue the enemy until they leave that range. If no more enemies are within range they will return to their original positions.

Stand Ground or Last Stand

pYdMZ.png

Behavior: Will not move unless tasked to move or attack. Soldiers will not pursue enemy units and will only fight back when attacked or when their comrade next to them in formation is being attacked. This behavior is the default for the Testudo and Syntagma formations (and perhaps others).

Avoid or Passive

QB0cm.png

Behavior: Default (and only) stance for support units. Will not attack. Runs away from enemy soldiers in the direction of the nearest Civ Centre or Fortress. A unit with this stance, if tasked to move, will attempt to avoid contact with enemy units. This is the default stance when the Scout command is given to cavalry; if scout(s) come under enemy fire they will attempt to circumnavigate that fire while at the same time completing their way pointed mission. If idle, and attacked, these scouts will run away in the direction of the player's nearest Civic Centre or Fortress.

Edited by Mythos_Ruler
Removed the "Choosing a Stance" section.

Share this post


Link to post
Share on other sites

A quick guide I whipped up. Subject to change based upon input from the team. I noticed that the Design Document in Trac no longer has information on such things.

Share this post


Link to post
Share on other sites

2 things:

In defensive mode, have units stop pursuing enemies once they exit the 10-tile radius. If they pursue them into the SoD, you may find a defensive unit wandering around the map if they're faster than the unit they're pursuing.

In passive mode, units should still respond to being attacked. If they just stand there and let themselves be killed, there is no purpose to this stance.

1 person likes this

Share this post


Link to post
Share on other sites

Ideally, passive units should have more speed (+25%), and flee from the enemy.

The scenario I'm thinking of is women. If they're attacked while farming, they drop what their doing, and run away (maybe town centre by default?).

Share this post


Link to post
Share on other sites

Ideally, passive units should have more speed (+25%), and flee from the enemy.

The scenario I'm thinking of is women. If they're attacked while farming, they drop what their doing, and run away (maybe town centre by default?).

This.

Share this post


Link to post
Share on other sites

I thought I should link this thread to this trac ticket http://trac.wildfire...com/ticket/865

My main concern is about the code in UnitAI.js which will grow steadily throughout the development process. If its not clean now, It will become a real mess over time.

So, I've got a few questions concerning simulation:

1/ Is there any requirement of maintaining C++ source as small as possible ? should I create new C++ functions when I need them or try to uses a javascript wrapper instead ?

e.g. if a C++ function take entity's position as parameter but that it's easier for me to call it with entity's id, can I overdefine it and expose it ?

2/ If I need to compute the distance between two entities, should I do it in CCmpPosition.cpp (+++), UnitAI.js (-) or in any helper.js (+?) file ?

3/ Is it possible to see how much time takes UnitAI to run ? (benchmarking purpose)

Theses questions will probably seems stupid, but.. need answers (I will take them as a guideline) in order to code remorseless and enjoying it :)

Share this post


Link to post
Share on other sites
1/ Is there any requirement of maintaining C++ source as small as possible ? should I create new C++ functions when I need them or try to uses a javascript wrapper instead ?

e.g. if a C++ function take entity's position as parameter but that it's easier for me to call it with entity's id, can I overdefine it and expose it ?

I prefer to keep the C++ interfaces simple, since that makes them easier to understand and to maintain, and then put the logic in the scripts since they're more flexible. Whenever you do anything with entity positions you have to check for e.g. !IsInWorld() and then respond in some appropriate way, and it's usually easier for the script to decide how to react than the C++ (since only the script knows the context in which it's running - maybe it will ignore the target, or maybe it will have remembered the last known position, or something). So I'd prefer not to pass entity IDs into C++ unless it's either necessary or hugely more convenient.

2/ If I need to compute the distance between two entities, should I do it in CCmpPosition.cpp (+++), UnitAI.js (-) or in any helper.js (+?) file ?

If it's a script that needs to know the distance, it's probably better to have the script do the computation (to keep the C++ interfaces simple; performance won't matter), and it should probably go in a new file in helpers/ since other code might want to use it (e.g. Attack.js already does some computing distances between units).

3/ Is it possible to see how much time takes UnitAI to run ? (benchmarking purpose)

Probably not with any accuracy at all. If you build in Debug mode then the F11 profiler should show script functions, but it disables the JIT so it's very unrepresentative. Alternatively you can do Engine.ProfileStart("some name") / Engine.ProfileStop() to explicitly add a region to the profiler tree (it'll be somewhere in the 'simulation update' branch, I think), though the profiler has some cost itself so it'll distort the results if you're timing very short intervals.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for your answer Philip.

I commited a patch. Feel free to tell me / change all the things you don't like. :D

Share this post


Link to post
Share on other sites

I love the Icons, Mythos Ruler. My only comment would be that the selected stance is not clear enough to see, compared to the other stances. Maybe make the Selected stance icon turn bigger than the others or make the colour difference bigger?

Share this post


Link to post
Share on other sites

I love the Icons, Mythos Ruler. My only comment would be that the selected stance is not clear enough to see, compared to the other stances. Maybe make the Selected stance icon turn bigger than the others or make the colour difference bigger?

If I had my way, the stance you select will be easy to see because it's the only one you see. :)

My idea is to click the icon next to the unit portrait, the stance icons pop up, you click one, then the stances go away and the one you chose is now the icon you originally clicked on.

Share this post


Link to post
Share on other sites

Like this.

Click the sword/shield icon, which in this case should mean he is currently in Defensive stance.

TynBz.png

Little menu pops open.

eAazM.png

Click.

Then the menu goes away and the icon changes to what you clicked.

The menu can pop up, down, left, right, I don't care. :)

"Passive" would not need to be shown, since Passive is only a default behavior of support units and when you put Cavalry units in scout mode.

Share this post


Link to post
Share on other sites

Interesting, I agree it is well-placed there. But maybe you'll need another place then for the parameters like Attack damage, armour and range.

Share this post


Link to post
Share on other sites

Interesting, I agree it is well-placed there. But maybe you'll need another place then for the parameters like Attack damage, armour and range.

Well, currently you mouseover to get the tooltip that tells you this. No reason we couldn't continue.

Share this post


Link to post
Share on other sites

I really like those stance icons. The icons could just toggle from one to the other, giving more space for other stuff.

Share this post


Link to post
Share on other sites

Eh, could work. Might be a bit annoying to have to click three times to get to the "previous" stance. It would be great if, like Homeworld, stances were linked to some hotkeys. So whenever you pressed, say, F4, the selected unit would go to agressive. F5 would put them in Stand Ground, etc.

Share this post


Link to post
Share on other sites

I really like those stance icons. The icons could just toggle from one to the other, giving more space for other stuff.

There's a thought (y)

Share this post


Link to post
Share on other sites

Eh, could work. Might be a bit annoying to have to click three times to get to the "previous" stance.

Left click for back, right click for forward.

Share this post


Link to post
Share on other sites

I think the stance icons should always be shown, if possible. Either lined up next to the unit portrait or grouped with the formation panel (there's empty space there, too).

Share this post


Link to post
Share on other sites

I think the stance icons should always be shown, if possible. Either lined up next to the unit portrait or grouped with the formation panel (there's empty space there, too).

This is possible (grouped with the formations), and one idea I had considered. Have to take a look at the formations to make sure there isn't an instance where we need the whole panel to show all the formations. If there is never an instance where the bottom row is taken, then let's put them there.

Share this post


Link to post
Share on other sites

With the formations is probably best since i just thought of another problem, how to set up the stances to work with a selection of units. It would be a horrible pain to have to set each units stance individually, especially if you wanted to switch an entire platoons stance just before they engage the enemy.

Share this post


Link to post
Share on other sites

Yes, of course you will be able to change the stance of multiple units at once. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0