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 2)
4 Pages1 2 3 4 
on Dec 12, 2009

Scoutdog
This is very good news for us modders, and it should help quite the endless damage-types debate........ once we get things in our hot little hands, I'll begin taking requests for new damage systems from those of you who care about that sort of thing.....

I am not a coder so forgive my ignorance....this means that we can mod in new damage types & resistances & immunities for example?

on Dec 12, 2009

this means that we can mod in new damage types & resistances & immunities for example?
This is the first step towards that. The second step will be in the battle logic, where we'd need to allow these 'Unit Stat Types' to have a data-driven way to interact with other stats.

But yeah, I don't see any reason why modding these sorts of things will be an issue (come v1.0).

on Dec 12, 2009

Strangely enough I was just wondering their would be much use of morale in the game...it could make things much different.

on Dec 12, 2009

-alpha666-
I am not sure if it is related but,
I found it really effective  to be able to define primary stats and secundary stats in XML ( for exemple, let us take vitality as base stats and hit points as a secundary stat ... meaning it calculated by a formula from the base stats) .
To define a comportement fully on xml, it is possible to add even the formulas in XML.Here is an example of what is possible to make ( the engine is in C#)

Using C# 3.0 it's even possible to transform those formulas to C# compiled code You can use the Shunting-Yard algorithm to transform the formula to postfix notation and then transform that (a stack of operators and values) into an expression tree (System.Linq.Expressions) and then compile that, and voila, your XML is now C# code

I wrote a little about this (in Spanish) some months ago if anyone wants to check (google translate works pretty nicely):

http://kartones.net/blogs/jadengine/archive/2009/02/09/implementando-el-reglamendo-de-un-rpg.aspx (basic system, shunting-yard)

http://kartones.net/blogs/jadengine/archive/2009/03/31/193-rboles-de-expresiones.aspx (transforming a formula to code using expresion trees).

on Dec 12, 2009

Can it be written:

<UnitStatType  InternalName="UnitStat_BluntAttack"

DisplayName="Blunt Attack"

Icon="Icon_Club.png"

Description="The blunt damage this unit will deal when attacking." />

(Edit: Indentation fail here - I like to have these things line up vertically so you can just scan down them.)

Since none of these things look like you will be able to have more than one of them there doesn't seem to be any reason to make them elements rather than attributes. Furthermore, you have an element which is called 'Attribute'. Perhaps there is a reason for this but it looks like a recipe for confusion to me?

What I'd really like would be a plain old hashmap literal (something along these lines, varies with language):

 

UnitStatType = { 
	InternalName = "Unit";
	DisplayName = "Blunt Attack";
	Icon = "Icon_Club.png";
	Description = "The blunt damage this unit will deal when attacking.";
};
I'm pleased to see that these things are moddable, but I have a phobia of typing more angle brackets than are absolutely necessary 

 

on Dec 12, 2009

BoogieBac

this means that we can mod in new damage types & resistances & immunities for example?This is the first step towards that. The second step will be in the battle logic, where we'd need to allow these 'Unit Stat Types' to have a data-driven way to interact with other stats.


But yeah, I don't see any reason why modding these sorts of things will be an issue (come v1.0).

Oh, awesome!

on Dec 12, 2009

Nights Edge
Can it be written:

<UnitStatType  InternalName="UnitStat_BluntAttack"

DisplayName="Blunt Attack"

Icon="Icon_Club.png"

Description="The blunt damage this unit will deal when attacking." />
 

+1. It would be neater indeed.

I wonder if there's any typing restrictions (integer/float/string/array) with regards to what you can put inside an attribute. If the underlying data structure is python, there shouldn't, if it's C++, there probably is (unless you have a wrapper around python types or something).

on Dec 12, 2009

Ok, thanks for this short and cool developer's battle report (against the "demons of the code"). One question though. Let's say we put all the attributes that we would like to have in the attributes.xml. Now, how to make it work in the game? I mean: do we just create a file called battle.py, which will take care of the battle? Or will there be a different system?

on Dec 12, 2009

I mean: do we just create a file called battle.py, which will take care of the battle? Or will there be a different system?
  I'll pass that along as those systems are finalized

on Dec 13, 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?

If you can't share I understand, I'm highly curious though

on Dec 13, 2009

More moddability is always good  (Civilization 4 is a nice exampl of this, been playing a lot of mods in it recently), so it's nice ot see that these sorts of things are included.

on Dec 14, 2009

Hum .. so ... we have "blunt damage". Will armor be able to acts accrodingly ? Like if I have a full plate armor. Will I be able to tell the comp to lessen damage if the armor is an "anti-blunt damge" ?

on Dec 14, 2009

Hum .. so ... we have "blunt damage". Will armor be able to acts accrodingly ? Like if I have a full plate armor. Will I be able to tell the comp to lessen damage if the armor is an "anti-blunt damge" ?

That's the plan, but since that gets into the 'battle logic' side of things, I don't have many details. But right now, you can (in XML) assaign 'Blunt Attack' to weapons and 'Blunt Defense' to armor. You can even make a spall, potion, or event that raises either of these values.  AH, the joys of data-driven code

on Dec 14, 2009

Good news ! Will we be able to do that .. with spells ? Weapons ?

Will I be able to create a fire elemental that have "fire armor" and "water weakness" ? And add some tag to swords like "water damage" and add to the battle logic that a "fire damage" will be increased versus a "fire weakness" ?

If so, I don't understand the need for separate damage "types" (and all the heated discussion about just "magical" and "mundane" damage), because a simple tag will be able to handle all the jazz about fire elemental, ice sword, earth chickens and wind spoons.

*crosses fingers*

on Dec 14, 2009

BoogieBac

Hum .. so ... we have "blunt damage". Will armor be able to acts accrodingly ? Like if I have a full plate armor. Will I be able to tell the comp to lessen damage if the armor is an "anti-blunt damge" ?


That's the plan, but since that gets into the 'battle logic' side of things, I don't have many details. But right now, you can (in XML) assaign 'Blunt Attack' to weapons and 'Blunt Defense' to armor. You can even make a spall, potion, or event that raises either of these values.  AH, the joys of data-driven code

Sounds awesome Boogie! It looks like that hardcore strategy gamers can have their fun with the game as well, because of the powerful modding features!

4 Pages1 2 3 4