Where once there was an Array there is now a std::Map
Published on December 11, 2009 By ScottTykoski In Elemental Dev Journals
Wow, what a week. A task that I had assumed would take 1.5 days ended up sucking up around 32 hours. While my lack of scheduling foresight sucks, the time was DEFIANTLY worth it to have this vital feature done right...
 
In previous builds, all unit stat handling was done with a basic array of stats.  There was a hard-coded list of what could and could not be stored in it (Strength, Defense, and HP to name a few). It worked, but with several new stats in the pipeline (Magic Attack, Magic Strength, Structural Damage) and the ongoing discussion on other damage types, I figured it was time to rework the system in a data-friendly way.
 
We now store all unit stat data in what are called MAPS, where entries are sorted by a STRING, opposed to a numeric INDEX. Now, instead of using afStats[1] to get hit points, the developers use mapfStats['HitPoints']. We also have a file that defines the given stats for the game...
 
<UnitStatType InternalName="UnitStat_HitPoints">
<DisplayName>Hit Points</DisplayName>
<Icon>Icon_Heart.png</Icon>
<Description>How much damage a unit can endure before kickin' the bucket.</Description>
</UnitStatType>
 
The above would let the game know that 'UnitStat_HitPoints' is a valid unit stat. You could then add a stat type by defining it in XML...
 
<UnitStatType InternalName="UnitStat_BluntAttack">
<DisplayName>Blunt Attack</DisplayName>
<Icon>Icon_Club.png</Icon>
<Description>The blunt damage this unit will deal when attacking.</Description>
</UnitStatType>
 
You then add a stat modifier to a weapon...
 
<GameMod>
<Type>Unit</Type>
<Attribute>UnitStat_BluntAttack</Attribute>
<Value>5<Value>
</GameMod>

And the game will know that any unit with that weapon does 5 points blunt attack.  Hooking this up to the battle system in a data-driven fashion will be another adventure, but at least the raw data is now organized and manageable. A good week...even if I wish I had more to show for it

Comments (Page 3)
4 Pages1 2 3 4 
on Dec 14, 2009

Hey Boogie, I understand nothings set in stone until the game ships, I was just curious if you could share Stardocks current plans for overall unit stats in Elemental? Maybe even what ideas you've all been throwing around?

Sorry, missed this one

Right now, for all units, we're looking at...
Attack
Range (how far the weapon can reach)
Armor (Defense)
Magic
Magic Resistance
Hit Points
Combat Speed
Moves (per Turn on main map)
Sight


With Heroes and Sovereign units getting a few extra RPG stats that will affect the above base values...
Strength
Intelligence
Wisdon
Charisma
Constitution
Dexterity
Essence

...and all that is subject to change at a moment's notice   But I think we're finally coming to the final set of stats.

 

on Dec 14, 2009

Awesome boogie! thanks for sharing

I've seen Morale thrown around in a thread or two, was it cut as a stat? or is it simply a type of bonus or penalty that gets applied to a unit?

Regardless, the stats are looking good.

on Dec 14, 2009

Do the RPG-style extra stats only give bonuses to the base stats? Or do they do other things?

on Dec 15, 2009


It is great that Weapon Reach is in.   It'll be very useful stat, relates to flanking and/or first strike.
 
I am proposing a new stat Leadership Cost & Leadership Value, which determine the number of units a hero can improve their base value.    I really like the direction of letting a hero changes unit's base stat.

on Dec 15, 2009

Where is the morale stat ? won't there be one ? It could really add a lot to the battle mechanism.

on Dec 15, 2009

I've seen Morale thrown around in a thread or two, was it cut as a stat?

I beleive the current thinking is to have that an army-wide stat, based on various factors (tide of battle, relations, etc.) and only applicable in battle, but it'd be pretty easy to make that a per-unit stat.

on Dec 15, 2009

Historically, armies didn't always break at the same time, but parts of armies usually did.  I like the idea of a "Discipline" stat, too, but it's probably redundant with Morale.  Basically, I don't want untrained peasants able to form close ranks and march in formation quickly.  Well-trained troops should have advantages in speed, reaction time, and maneuverability.

Boogie - How do you see that type of thing being reflected?  Are unit formations, etc. going to come with tech and be like an "item" used by a given troop type?

on Dec 15, 2009

I'll be interested in seeing how "base game" morale developes as well (If it is included).

on Dec 15, 2009

BoogieBac

I've seen Morale thrown around in a thread or two, was it cut as a stat?
I beleive the current thinking is to have that an army-wide stat, based on various factors (tide of battle, relations, etc.) and only applicable in battle, but it'd be pretty easy to make that a per-unit stat.

A whole "morale" thing about the tide of battle is good .. and it should affect the morale checks units would do when they see ding their friends.

Every units with a morale stat should make a roll when too much people die next to them and/or are breaking. The army-wide "morale" could be a bonus/malus to that roll. The discipline of a unit would be a bonus to that check. The "Will" would add a bonus only when the life of the unit is threatened.

What I liked about Medieval total war is the fact that breaking a piece of an army could get a "wave" effect where units near the breaking units would break and so on.

on Dec 15, 2009

Yeah, the Total War series has replicated the morale effect very effectively since Shogun.  I'll never forget this one battle I had in Shogun: a very large enemy army was advancing up the hill towards me.  I basically had archers and heavy cavalry.  the archers were causing some casualties, but were going to get hit.  So I dispersed them, and then moved my heavy cav through their ranks.  The enemy line wavered visually, and as the heavy cavalry got about half way to them, they broke in an expanding ripple, starting at the center unit and moving to both flanks in a matter of seconds.  It was one of those "that was cool" moments.

on Dec 15, 2009

Is Armor (Defense) going to be damage reduction or evasion? I hope it is reduction and there is a separate attribute called evasion or dodge. It always kind of bugged me when armor was really evasion in a game instead of actually being armor. 

on Dec 15, 2009

All this sounds nice, but won't it run slower than a more old-fashioned, hard-wired approach?

PLEASE tell me that no part of this game will run as slowly as the "next-turn" in HOMM5 with max-size maps and max # of AI players.

on Dec 16, 2009

Lord Cobol
All this sounds nice, but won't it run slower than a more old-fashioned, hard-wired approach?

PLEASE tell me that no part of this game will run as slowly as the "next-turn" in HOMM5 with max-size maps and max # of AI players.

Flexibility and performance are trade offs. But is hard to prove that if you have a speed problem, hard-wiring things is the best approach to solve it instead of refactoring code, improving algorithms and other things.

So I wouldn't attack performance issues hard-wiring if is not the last resort, there are plenty of other things that can be tried first.

on Dec 16, 2009

All this sounds nice, but won't it run slower than a more old-fashioned, hard-wired approach?
  You're still looping through a list of stats, only now that list size is variable. I suppose I could see some miniscule hit to performance if you have 100+ extra stats thrown into the game that it has to sort through, but even then it wouldn't be close to the hit you'd get from something graphical in nature (increasing resolution, switching to 8x AA, etc.).

on Dec 16, 2009

I'm also in favor of a morale stat. That morale be checked per bunch of units is good, but each formation can make a morale check on its own based on the average morale stat of each of their members.

4 Pages1 2 3 4