Hi everyone,
this post is about last weeks work, implementing 5 enemies for Soulcraft.
Here is a screenshot from the editor showing off the enemies:
Ghost, Berserker, Warlock, Felhound and Succubus.

(The content is low-res version for iPhone)
Some information about the editor:
The editor also uses the DeltaEngine for rendering the scene, handling input etc.
Also most code is shared between game and editor, so adding new stuff is really easy:
Just implement a new enemy inside Soulcraft, and it shows up in the editor.
Sample code from Felhound enemy:
Code:public class FelHound : CannonFodder
{
#region Constructor
/// <summary>
/// Create fel hound
/// </summary>
public FelHound(Vector setPosition, Vector setOrientation)
: base("Felhound", setPosition, setOrientation)
{
Race = UnitRace.Demon;
// LowContent
animations.Add(new Animation("Idle", 144, 173, true));
animations.Add(new Animation("Walk", 0, 30, true));
animations.Add(new Animation("Attack", 112, 143, false, false, 0.1f));
animations.Add(new Animation("Die", 31, 111, false, false, 0.1f));
animations.Add(new Animation("GetHit", 174, 200, false));
animations.Add(new Animation("Run", 201, 255, true));
animations.Add(new Animation("Stun", 256, 306, true));
// Sounds
spawnSoundName = "wpn_emit_hellhound_howl";
dieSoundName = "enmy_efx_demon_die_hellhound";
AttackSoundName = "wpn_emit_hellhound_bite";
// Attack mana leech effect
AttackEffectName = "ManaLeech";
// Setup Energy steal
EnergyStealBuff energyStealBuff = new EnergyStealBuff(this);
energyStealBuff.Percentage = 2.0f;
energyStealBuff.Activate(this);
} // FelHound(setPosition, setOrientation)
#endregion
} // class FelHound
In fact, this is all what is needed to add a new enemy into Soulcraft from coding point of view.
(of course you have to adjust his attackdamage, movementspeed afterwards)
In Soulcraft we have a sophisticated entity hierarchy, so our FelHound class inherits from CannonFodder,
which sets up some AI settings common for all enemies of given type.
Cannonfodder itself inherits from BaseEnemy (common stuff for all enemies), then BaseUnit (common stuff for all unit entities, like health, mana etc.), then ModelEntity.
ModelEntity is interesting for DeltaEngine users, as it encapsulates a DeltaEngine Mesh.
Back when we started Soulcraft development, there was no support for different animation sets.
(Like "Run", "Walk", "Attack" etc.)
But since DeltaEngine is opensource we could easily extend the Mesh class to support sets of animation,
implement animation blending and inter-frame interpolation.
Code:// Model constructor
//(it is just a mesh, with some special handling for its animation data)
public Model(string contentName)
{
Mesh = new Mesh(contentName);
// Extract animation data
if (Mesh.AnimationData != null)
{
Animation = new Animation(Mesh.AnimationData);
}
}
Here is a snippet showing the actual bone matrix blending between two different animations.
Code:Matrix[] finalBoneMatrices =
new Matrix[blendAnimation.BoneMatrices.Length];
// Calculate the final bone matrices.
for (int i = 0; i < finalBoneMatrices.Length; i++)
{
finalBoneMatrices[i] =
Matrix.Multiply(blendAnimation.BoneMatrices[i], (1.0f - blendFactor)) +
Matrix.Multiply(animation.BoneMatrices[i], blendFactor);
}
Hope you enjoyed reading,
Heiko
Edited by user Wednesday, August 31, 2011 12:49:38 PM(UTC)
| Reason: Not specified