David
[ Biography ] [ Flash ] [ C/C++ ] [ Python ] [ C# ] [ Artwork ] [ Resume ] [ Contact ]

 

banner "A RISK based strategy game played in real time."

Manifest Destiny is a three-dimensional, RISK-based, real time strategy game developed in C++ using the Ogre3D Graphics Engine and D3D9. I and three other Ohio State students developed the game in an 8-week timespan, working practically full-time.

I was personally credited with developing:

  • General gameplay/user mechanics (such as unit selection, map navigation, movement commands, etc..)
  • Flocking and collision avoidance algorithms (unit collision avoidance, squad formation and manuvering, pathfinding)
  • Enemy artificial intelligence ('clumping algorithm,' progression of play, unit spawn ratios, attack sequences)
  • Model/animation loading and executing (getting all the Torchlight models to animate properly and look pretty)
  • Particle effects (Magi spellcasting, unit deaths, and fire)
  • Water effects (build using the Ogre plug-in Hydrax)
I helped code almost everything within the game; the only pieces I had absolutely no part of were the HUD (skins, mini-map, buttons), the installer, and sound effects throughout.

The game was packaged with a windows installer, detailed design document, abstract, and an analysis of major algorithms. The game and code base is made up of about 1,700 files within 101 folders, and was written in 20,000+ lines of C++ code. Several code snippets and examples are provided below.




List of Programmed Features:

  • Particle Effects
  • Animated Torchlight Models
  • Terrain Clamping
  • Terrain Texture Splatting
  • Random Barracks Spawns
  • Event-Based Systems
  • Custom Minimap
  • Four Unique HUDs
  • Hardware Consideration (Regulating Framerate)
  • Beautiful Water Effects
  • Fully Autonomous Enemy AI
  • Squad Flocking
  • Collision Detection and Avoidance
  • Volume Selection
  • Projected Decals

Additional Programmed Features:

  • Three Simultaneous Enemies
  • Barracks Upgrades and Visual Cues
  • Buy Option Tool-Tips
  • Balanced Gameplay
  • Income-Based Game Model
  • Multi-Threaded Preloading
  • XML-Driven Maps
  • Statistic-Based Displays
  • Health Bar Visuals
  • Rich Sound Effects
  • Camera Pivoting
  • Barracks' Rally Points
  • Standard Windows Installer
  • Auto-Attack Capabilities
  • Pause Functionality
  • Volume Settings


UnitMap
Design Document

The diagram on the left is an abstract representation of our entire unit hierarchy. To allow for a clean and efficient code-base, everything is extended from a core unit class with the basic/necessary virtual functions and variables. Then, each of the four unit types is extend from base unit (Brute, Scout, Ranged, Magi); adding components such as mana, cool-downs, and then the initialization of specific variables. Finally, off of each unit type, specific race implementations are set. These include the actual imported Torchlight models and their corresponding animation sets.


To the right is a comparative chart between the four core unit types. Gameplay was tested numerous times to properly determine balanced prices. And in the end, we decided on these settings.

Both these charts come from our design document. To view the entire thing, you can access that here.
PriceChart
Unit.cpp --   This is our actual implementation of the diagram above. It includes all the construtors for each unit type in the game.
*MANY more code samples are available upon request

  1. #include "Unit.h"
  2. #define size_indicator 40
  3.  
  4. C_Brute::C_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  5.  
  6.   //initialize character settings
  7.   C_Brute::damage = BRUTE_DAMAGE;
  8.   C_Brute::walkSpeed = BRUTE_WALKSPEED;
  9.   C_Brute::health = BRUTE_HEALTH;
  10.   C_Brute::attackSpeed = BRUTE_ATTACKSPEED;
  11.   C_Brute::attackRange = BRUTE_ATTACKRANGE;
  12.   C_Brute::isAttacking = false;
  13.   C_Brute::moving = 0;
  14.   C_Brute::selected = false;
  15.   curTargetWeight = -1;
  16.   targetBarracks = NULL;
  17.   targetUnit = NULL;
  18.   //create entity
  19.   sprintf(C_Brute::name, "CB%d", ID);  
  20.   C_Brute::mEntity = mSceneMgr->createEntity(C_Brute::name, "robot.mesh");
  21.   C_Brute::mEntity->setQueryFlags(CYBORG_MASK);
  22.   C_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  23.   //set animation
  24.   C_Brute::mAnimationState = C_Brute::mEntity->getAnimationState("Idle");
  25.   C_Brute::mAnimationState->setLoop(true);
  26.   C_Brute::mAnimationState->setEnabled(true);
  27.  
  28.   //create this unit's sceneNode
  29.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  30.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  31.   ent->attachObject(mEntity);
  32.   ent->setScale(scale);
  33.   ent->setOrientation(rot);
  34.  
  35.  
  36.   
  37.   //minimap indicator 0426-abe
  38.   char i[7];
  39.   sprintf(i, "CBi%d\0", ID);
  40.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  41.   set->setPoolSize(1);
  42.   set->setMaterialName("Examples/IndicatorC");
  43.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  44.   set->setVisibilityFlags(MINIMAP_MASK);
  45.   me->setDimensions(size_indicator, size_indicator);
  46.   C_Brute::mUnit->attachObject(set);
  47.  
  48.   //health box
  49.   char health[8];
  50.   sprintf(health, "CBhp%d\0", ID);
  51.   C_Brute::hpSet = mSceneMgr->createBillboardSet(health);
  52.   hpSet->setPoolSize(1);
  53.   hpSet->setMaterialName("Examples/HP");
  54.   hpSet->setSortingEnabled(true);
  55.   Ogre::Billboard* hp = hpSet->createBillboard(0, 25, 0);
  56.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  57.   C_Brute::mUnit->attachObject(hpSet);
  58.  
  59.  
  60.   //build decal
  61.   dec = new TerrainDecal(Ogre::String(C_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  62.   dec->hide();
  63.  
  64.   //start cooldown timer
  65.   C_Brute::cdTimer.reset(); proximityToken = NULL;
  66. }
  67.  
  68. C_Brute::C_Brute(){};
  69.  
  70. C_Scout::C_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  71.   curTargetWeight = -1;
  72.   //initialize character settings
  73.   C_Scout::damage = SCOUT_DAMAGE;
  74.   C_Scout::walkSpeed = SCOUT_WALKSPEED;
  75.   C_Scout::health = SCOUT_HEALTH;
  76.   C_Scout::attackSpeed = SCOUT_ATTACKSPEED;
  77.   C_Scout::attackRange = SCOUT_ATTACKRANGE;
  78.   C_Scout::isAttacking = false;
  79.   C_Scout::moving = 0;
  80.   C_Scout::selected = false;
  81.  
  82.   targetBarracks = NULL;
  83.   targetUnit = NULL;
  84.   //create entity
  85.   sprintf(C_Scout::name, "CS%d", ID);  
  86.   C_Scout::mEntity = mSceneMgr->createEntity(C_Scout::name, "Mech_Crawler.MESH");
  87.   C_Scout::mEntity->setQueryFlags(CYBORG_MASK);
  88.   C_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  89.  
  90.     //BONE ANIMATION SETUP
  91.   Ogre::SkeletonInstance* pSK = C_Scout::mEntity->getSkeleton();
  92.   pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Idle.SKELETON");
  93.   pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Run.SKELETON");
  94.   pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Attack1.SKELETON");
  95.  
  96.   //STORE THE ANIMATIONS
  97.   Ogre::AnimationStateSet* pass = C_Scout::mEntity->getAllAnimationStates();
  98.   pass->removeAllAnimationStates();
  99.   pass->createAnimationState("Idle", 0, 6.2);
  100.   pass->createAnimationState("Run", 0, 4.26);
  101.   pass->createAnimationState("Attack1", 0, 6.53);
  102.  
  103.   //set animation
  104.   C_Scout::mAnimationState = C_Scout::mEntity->getAnimationState("Idle");
  105.   C_Scout::mAnimationState->setLoop(true);
  106.   C_Scout::mAnimationState->setEnabled(true);
  107.  
  108.   //create this unit's sceneNode
  109.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  110.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  111.   ent->attachObject(mEntity);
  112.   ent->setScale(scale);
  113.   ent->setOrientation(rot);
  114.  
  115.  
  116.   
  117.   //minimap indicator 0426-abe
  118.   char i[7];
  119.   sprintf(i, "CSi%d\0", ID);
  120.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  121.   set->setPoolSize(1);
  122.   set->setMaterialName("Examples/IndicatorC");
  123.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  124.   set->setVisibilityFlags(MINIMAP_MASK);
  125.   me->setDimensions(size_indicator, size_indicator);
  126.   C_Scout::mUnit->attachObject(set);
  127.  
  128.   //health box
  129.   char health[8];
  130.   sprintf(health, "CShp%d\0", ID);
  131.   C_Scout::hpSet = mSceneMgr->createBillboardSet(health);
  132.   hpSet->setPoolSize(1);
  133.   hpSet->setMaterialName("Examples/HP");
  134.   hpSet->setSortingEnabled(true);
  135.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  136.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  137.   C_Scout::mUnit->attachObject(hpSet);
  138.  
  139.  
  140.   //build decal
  141.   dec = new TerrainDecal(Ogre::String(C_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  142.   dec->hide();
  143.  
  144.   //start cooldown timer
  145.   C_Scout::cdTimer.reset(); proximityToken = NULL; proximityToken = NULL;
  146.   proximityToken = NULL;
  147. }
  148.  
  149. C_Scout::C_Scout(){};
  150.  
  151. C_Ranged::C_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  152.   curTargetWeight = -1;
  153.   //initialize character settings
  154.   C_Ranged::damage = RANGED_DAMAGE;
  155.   C_Ranged::walkSpeed = RANGED_WALKSPEED;
  156.   C_Ranged::health = RANGED_HEALTH;
  157.   C_Ranged::attackSpeed = RANGED_ATTACKSPEED;
  158.   C_Ranged::attackRange = RANGED_ATTACKRANGE;
  159.   C_Ranged::isAttacking = false;
  160.   C_Ranged::moving = 0;
  161.   C_Ranged::selected = false;
  162.  
  163.   targetBarracks = NULL;
  164.   targetUnit = NULL;
  165.   //create entity
  166.   sprintf(C_Ranged::name, "CR%d", ID);  
  167.   C_Ranged::mEntity = mSceneMgr->createEntity(C_Ranged::name, "fortress_ballista_01.MESH");
  168.   C_Ranged::mEntity->setQueryFlags(CYBORG_MASK);
  169.   C_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  170.  
  171.     //BONE ANIMATION SETUP
  172.   Ogre::SkeletonInstance* pSK = C_Ranged::mEntity->getSkeleton();
  173.   pSK->addLinkedSkeletonAnimationSource("C_Ranged/armed.SKELETON");
  174.   pSK->addLinkedSkeletonAnimationSource("C_Ranged/attack.SKELETON");
  175.  
  176.   //STORE THE ANIMATIONS
  177.   Ogre::AnimationStateSet* pass = C_Ranged::mEntity->getAllAnimationStates();
  178.   pass->removeAllAnimationStates();
  179.   pass->createAnimationState("armed", 0, 6.2);
  180.   pass->createAnimationState("attack", 0, 6.53);
  181.  
  182.   //set animation
  183.   C_Ranged::mAnimationState = C_Ranged::mEntity->getAnimationState("armed");
  184.   C_Ranged::mAnimationState->setLoop(true);
  185.   C_Ranged::mAnimationState->setEnabled(true);
  186.  
  187.   //create this unit's sceneNode
  188.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  189.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  190.   ent->attachObject(mEntity);
  191.   ent->setScale(scale);
  192.   ent->setOrientation(rot);
  193.  
  194.  
  195.   
  196.   //minimap indicator 0426-abe
  197.   char i[7];
  198.   sprintf(i, "CRi%d\0", ID);
  199.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  200.   set->setPoolSize(1);
  201.   set->setMaterialName("Examples/IndicatorC");
  202.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  203.   set->setVisibilityFlags(MINIMAP_MASK);
  204.   me->setDimensions(size_indicator, size_indicator);
  205.   C_Ranged::mUnit->attachObject(set);
  206.  
  207.   //health box
  208.   char health[8];
  209.   sprintf(health, "CRhp%d\0", ID);
  210.   C_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
  211.   hpSet->setPoolSize(1);
  212.   hpSet->setMaterialName("Examples/HP");
  213.   hpSet->setSortingEnabled(true);
  214.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  215.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  216.   C_Ranged::mUnit->attachObject(hpSet);
  217.  
  218.  
  219.   //build decal
  220.   dec = new TerrainDecal(Ogre::String(C_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  221.   dec->hide();
  222.  
  223.   //start cooldown timer
  224.   C_Ranged::cdTimer.reset(); proximityToken = NULL;
  225. }
  226.  
  227. C_Ranged::C_Ranged(){};
  228.  
  229. C_Magi::C_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  230.   curTargetWeight = -1;
  231.   //initialize character settings
  232.   C_Magi::damage = MAGI_DAMAGE;
  233.   C_Magi::walkSpeed = MAGI_WALKSPEED;
  234.   C_Magi::health = MAGI_HEALTH;
  235.   C_Magi::attackSpeed = MAGI_ATTACKSPEED;
  236.   C_Magi::attackRange = MAGI_ATTACKRANGE;
  237.   C_Magi::isAttacking = false;
  238.   C_Magi::moving = 0;
  239.   C_Magi::selected = false;
  240.  
  241.   targetBarracks = NULL;
  242.   targetUnit = NULL;
  243.   //create entity
  244.   sprintf(C_Magi::name, "CM%d", ID);  
  245.   C_Magi::mEntity = mSceneMgr->createEntity(C_Magi::name, "Mech_Construct.MESH");
  246.   C_Magi::mEntity->setQueryFlags(CYBORG_MASK);
  247.   C_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  248.  
  249.     //BONE ANIMATION SETUP
  250.   Ogre::SkeletonInstance* pSK = C_Magi::mEntity->getSkeleton();
  251.   pSK->addLinkedSkeletonAnimationSource("C_Magi/Idle.SKELETON");
  252.   pSK->addLinkedSkeletonAnimationSource("C_Magi/Run.SKELETON");
  253.   pSK->addLinkedSkeletonAnimationSource("C_Magi/Special_Spray_Left.SKELETON");
  254.  
  255.   //STORE THE ANIMATIONS
  256.   Ogre::AnimationStateSet* pass = C_Magi::mEntity->getAllAnimationStates();
  257.   pass->removeAllAnimationStates();
  258.   pass->createAnimationState("Idle", 0, 6.2);
  259.   pass->createAnimationState("Run", 0, 4.26);
  260.   pass->createAnimationState("Special_Spray_Left", 0, 6.53);
  261.  
  262.   //set animation
  263.   C_Magi::mAnimationState = C_Magi::mEntity->getAnimationState("Idle");
  264.   C_Magi::mAnimationState->setLoop(true);
  265.   C_Magi::mAnimationState->setEnabled(true);
  266.  
  267.   //create this unit's sceneNode
  268.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  269.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  270.   ent->attachObject(mEntity);
  271.   ent->setScale(scale);
  272.   ent->setOrientation(rot);
  273.  
  274.  
  275.   
  276.   //minimap indicator 0426-abe
  277.   char i[7];
  278.   sprintf(i, "CMi%d\0", ID);
  279.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  280.   set->setPoolSize(1);
  281.   set->setMaterialName("Examples/IndicatorC");
  282.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  283.   set->setVisibilityFlags(MINIMAP_MASK);
  284.   me->setDimensions(size_indicator, size_indicator);
  285.   C_Magi::mUnit->attachObject(set);
  286.  
  287.   //health box
  288.   char health[8];
  289.   sprintf(health, "CMhp%d\0", ID);
  290.   C_Magi::hpSet = mSceneMgr->createBillboardSet(health);
  291.   hpSet->setPoolSize(1);
  292.   hpSet->setMaterialName("Examples/HP");
  293.   hpSet->setSortingEnabled(true);
  294.   Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
  295.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  296.   C_Magi::mUnit->attachObject(hpSet);
  297.  
  298.   //spell particles
  299.   char spell[10];
  300.   sprintf(spell, "CMsp%d\0", ID);
  301.   C_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/chaingun");
  302.   C_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
  303.   sprintf(spell, "CMsp%dN", ID);
  304.   C_Magi::psNode = C_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
  305.   C_Magi::psNode->attachObject(C_Magi::ps);
  306.   C_Magi::psNode->translate(0,1,0);
  307.   C_Magi::psNode->pitch(Ogre::Degree(-90));
  308.   C_Magi::psNode->lookAt(C_Magi::mDirection,Ogre::Node::TS_WORLD);
  309.   C_Magi::ps->setVisible(false);
  310.   C_Magi::spellDir = Ogre::Vector3::ZERO;
  311.  
  312.   //build decal
  313.   dec = new TerrainDecal(Ogre::String(C_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  314.   dec->hide();
  315.  
  316.   //start cooldown timer
  317.   C_Magi::cdTimer.reset(); proximityToken = NULL;
  318. }
  319.  
  320. C_Magi::C_Magi(){};
  321.  
  322. H_Brute::H_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  323.   curTargetWeight = -1;
  324.   //initialize character settings
  325.   H_Brute::damage = BRUTE_DAMAGE;
  326.   H_Brute::walkSpeed = BRUTE_WALKSPEED;
  327.   H_Brute::health = BRUTE_HEALTH;
  328.   H_Brute::attackSpeed = BRUTE_ATTACKSPEED;
  329.   H_Brute::attackRange = BRUTE_ATTACKRANGE;
  330.   H_Brute::isAttacking = false;
  331.   H_Brute::moving = 0;
  332.   H_Brute::selected = false;
  333.  
  334.   targetBarracks = NULL;
  335.   targetUnit = NULL;
  336.  
  337.   //create entity
  338.   sprintf(H_Brute::name, "HB%d", ID);  
  339.   H_Brute::mEntity = mSceneMgr->createEntity(H_Brute::name, "dwarf.mesh");
  340.   H_Brute::mEntity->setQueryFlags(HUMAN_MASK);
  341.   H_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  342.  
  343.   //set animation
  344.   H_Brute::mAnimationState = H_Brute::mEntity->getAnimationState("Idle1");
  345.   H_Brute::mAnimationState->setLoop(true);
  346.   H_Brute::mAnimationState->setEnabled(true);
  347.  
  348.   //create this unit's sceneNode 0502-abe
  349.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  350.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  351.   ent->attachObject(mEntity);
  352.   ent->setScale(scale);
  353.   ent->setOrientation(rot);
  354.  
  355.   //minimap indicator 0426-abe
  356.   char i[7];
  357.   sprintf(i, "HBi%d\0", ID);
  358.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  359.   set->setPoolSize(1);
  360.   set->setMaterialName("Examples/IndicatorH");
  361.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  362.   set->setVisibilityFlags(MINIMAP_MASK);
  363.   me->setDimensions(size_indicator, size_indicator);
  364.   H_Brute::mUnit->attachObject(set);
  365.  
  366.  
  367.   //health bar
  368.   char health[8];
  369.   sprintf(health, "HBhp%d\0", ID);
  370.   H_Brute::hpSet = mSceneMgr->createBillboardSet(health);
  371.   hpSet->setPoolSize(1);
  372.   hpSet->setMaterialName("Examples/HP");
  373.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  374.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  375.   H_Brute::mUnit->attachObject(hpSet);
  376.  
  377.  
  378.   //build decal
  379.   dec = new TerrainDecal(Ogre::String(H_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  380.   dec->hide();
  381.  
  382.   //start cooldown timer
  383.   H_Brute::cdTimer.reset(); proximityToken = NULL;
  384. }
  385.  
  386. H_Brute::H_Brute(){};
  387.  
  388. H_Scout::H_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  389.   curTargetWeight = -1;
  390.   //initialize character settings
  391.   H_Scout::damage = SCOUT_DAMAGE;
  392.   H_Scout::walkSpeed = SCOUT_WALKSPEED;
  393.   H_Scout::health = SCOUT_HEALTH;
  394.   H_Scout::attackSpeed = SCOUT_ATTACKSPEED;
  395.   H_Scout::attackRange = SCOUT_ATTACKRANGE;
  396.   H_Scout::isAttacking = false;
  397.   H_Scout::moving = 0;
  398.   H_Scout::selected = false;
  399.  
  400.   targetBarracks = NULL;
  401.   targetUnit = NULL;
  402.  
  403.   //create entity
  404.   sprintf(H_Scout::name, "HS%d", ID);  
  405.  
  406.   H_Scout::mEntity = mSceneMgr->createEntity(H_Scout::name, "miner.MESH");
  407.   H_Scout::mEntity->setQueryFlags(HUMAN_MASK);
  408.   H_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  409.  
  410.   //BONE ANIMATION SETUP
  411.   Ogre::SkeletonInstance* pSK = H_Scout::mEntity->getSkeleton();
  412.   pSK->addLinkedSkeletonAnimationSource("H_Scout/idle.SKELETON");
  413.   pSK->addLinkedSkeletonAnimationSource("H_Scout/run.SKELETON");
  414.   pSK->addLinkedSkeletonAnimationSource("H_Scout/rslash1.SKELETON");
  415.  
  416.   //STORE THE ANIMATIONS
  417.   Ogre::AnimationStateSet* pass = H_Scout::mEntity->getAllAnimationStates();
  418.   pass->removeAllAnimationStates();
  419.   pass->createAnimationState("idle", 0, 6.2);
  420.   pass->createAnimationState("run", 0, 4.26);
  421.   pass->createAnimationState("rslash1", 0, 6.53);
  422.  
  423.  
  424.   //set animation
  425.   H_Scout::mAnimationState = H_Scout::mEntity->getAnimationState("idle");
  426.   H_Scout::mAnimationState->setLoop(true);
  427.   H_Scout::mAnimationState->setEnabled(true);
  428.  
  429.   //create this unit's sceneNode
  430.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  431.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  432.   ent->attachObject(mEntity);
  433.   ent->setScale(scale);
  434.   ent->setOrientation(rot);
  435.  
  436.   //minimap indicator 0426-abe
  437.  
  438.   char i[7];
  439.   sprintf(i, "HSi%d\0", ID);
  440.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  441.   set->setPoolSize(1);
  442.   set->setMaterialName("Examples/IndicatorH");
  443.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  444.   set->setVisibilityFlags(MINIMAP_MASK);
  445.   me->setDimensions(size_indicator, size_indicator);
  446.   H_Scout::mUnit->attachObject(set);
  447.  
  448.  
  449.   //health bar
  450.   char health[8];
  451.   sprintf(health, "HShp%d\0", ID);
  452.   H_Scout::hpSet = mSceneMgr->createBillboardSet(health);
  453.   hpSet->setPoolSize(1);
  454.   hpSet->setMaterialName("Examples/HP");
  455.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  456.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  457.   H_Scout::mUnit->attachObject(hpSet);
  458.  
  459.  
  460.   //build decal
  461.   dec = new TerrainDecal(Ogre::String(H_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  462.   dec->hide();
  463.  
  464.   //start cooldown timer
  465.   H_Scout::cdTimer.reset(); proximityToken = NULL;
  466. }
  467.  
  468. H_Scout::H_Scout(){};
  469.  
  470. H_Ranged::H_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  471.   curTargetWeight = -1;
  472.   //initialize character settings
  473.   H_Ranged::damage = RANGED_DAMAGE;
  474.   H_Ranged::walkSpeed = RANGED_WALKSPEED;
  475.   H_Ranged::health = RANGED_HEALTH;
  476.   H_Ranged::attackSpeed = RANGED_ATTACKSPEED;
  477.   H_Ranged::attackRange = RANGED_ATTACKRANGE;
  478.   H_Ranged::isAttacking = false;
  479.   H_Ranged::moving = 0;
  480.   H_Ranged::selected = false;
  481.   
  482.   targetBarracks = NULL;
  483.   targetUnit = NULL;
  484.  
  485.   //create entity
  486.   sprintf(H_Ranged::name, "HR%d", ID);  
  487.  
  488.   H_Ranged::mEntity = mSceneMgr->createEntity(H_Ranged::name, "Vanquisher.MESH");
  489.   H_Ranged::mEntity->setQueryFlags(HUMAN_MASK);
  490.   H_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  491.  
  492.   //BONE ANIMATION SETUP
  493.   Ogre::SkeletonInstance* pSK = H_Ranged::mEntity->getSkeleton();
  494.   pSK->addLinkedSkeletonAnimationSource("H_RANGED/idle.SKELETON");
  495.   pSK->addLinkedSkeletonAnimationSource("H_RANGED/Run.SKELETON");
  496.   pSK->addLinkedSkeletonAnimationSource("H_RANGED/Bow1.SKELETON");
  497.  
  498.   //STORE THE ANIMATIONS
  499.   Ogre::AnimationStateSet* pass = H_Ranged::mEntity->getAllAnimationStates();
  500.   pass->removeAllAnimationStates();
  501.   pass->createAnimationState("Idle", 0, 6.2);
  502.   pass->createAnimationState("Run", 0, 4.26);
  503.   pass->createAnimationState("Bow1", 0, 6.53);
  504.  
  505.  
  506.   //set animation
  507.   H_Ranged::mAnimationState = H_Ranged::mEntity->getAnimationState("Idle");
  508.   H_Ranged::mAnimationState->setLoop(true);
  509.   H_Ranged::mAnimationState->setEnabled(true);
  510.  
  511.   //create this unit's sceneNode
  512.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  513.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  514.   ent->attachObject(mEntity);
  515.   ent->setScale(scale);
  516.   ent->setOrientation(rot);
  517.  
  518.   //minimap indicator 0426-abe
  519.  
  520.   char i[7];
  521.   sprintf(i, "HRi%d\0", ID);
  522.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  523.   set->setPoolSize(1);
  524.   set->setMaterialName("Examples/IndicatorH");
  525.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  526.   set->setVisibilityFlags(MINIMAP_MASK);
  527.   me->setDimensions(size_indicator, size_indicator);
  528.   H_Ranged::mUnit->attachObject(set);
  529.  
  530.  
  531.   //health bar
  532.   char health[8];
  533.   sprintf(health, "HRhp%d\0", ID);
  534.   H_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
  535.   hpSet->setPoolSize(1);
  536.   hpSet->setMaterialName("Examples/HP");
  537.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  538.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  539.   H_Ranged::mUnit->attachObject(hpSet);
  540.  
  541.  
  542.   //build decal
  543.   dec = new TerrainDecal(Ogre::String(H_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  544.   dec->hide();
  545.  
  546.   //start cooldown timer
  547.   H_Ranged::cdTimer.reset(); proximityToken = NULL;
  548. }
  549.  
  550. H_Ranged::H_Ranged(){};
  551.  
  552. H_Magi::H_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  553.   curTargetWeight = -1;
  554.   //initialize character settings
  555.   H_Magi::damage = MAGI_DAMAGE;
  556.   H_Magi::walkSpeed = MAGI_WALKSPEED;
  557.   H_Magi::health = MAGI_HEALTH;
  558.   H_Magi::attackSpeed = MAGI_ATTACKSPEED;
  559.   H_Magi::attackRange = MAGI_ATTACKRANGE;
  560.   H_Magi::isAttacking = false;
  561.   H_Magi::moving = 0;
  562.   H_Magi::selected = false;
  563.  
  564.   targetBarracks = NULL;
  565.   targetUnit = NULL;
  566.  
  567.   //create entity
  568.   sprintf(H_Magi::name, "HM%d", ID);  
  569.  
  570.   H_Magi::mEntity = mSceneMgr->createEntity(H_Magi::name, "mage.MESH");
  571.   H_Magi::mEntity->setQueryFlags(HUMAN_MASK);
  572.   H_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  573.  
  574.   //BONE ANIMATION SETUP
  575.   Ogre::SkeletonInstance* pSK = H_Magi::mEntity->getSkeleton();
  576.   pSK->addLinkedSkeletonAnimationSource("H_Magi/Idle.SKELETON");
  577.   pSK->addLinkedSkeletonAnimationSource("H_Magi/Fidget1.SKELETON");
  578.  
  579.   //STORE THE ANIMATIONS
  580.   Ogre::AnimationStateSet* pass = H_Magi::mEntity->getAllAnimationStates();
  581.   pass->removeAllAnimationStates();
  582.   pass->createAnimationState("Idle", 0, 6.2);
  583.   pass->createAnimationState("Fidget1", 0, 6.26);
  584.  
  585.   //set animation
  586.   H_Magi::mAnimationState = H_Magi::mEntity->getAnimationState("Idle");
  587.   H_Magi::mAnimationState->setLoop(true);
  588.   H_Magi::mAnimationState->setEnabled(true);
  589.  
  590.   //create this unit's sceneNode
  591.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  592.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  593.   ent->attachObject(mEntity);
  594.   ent->setScale(scale);
  595.   ent->setOrientation(rot);
  596.  
  597.   //minimap indicator 0426-abe
  598.  
  599.   char i[7];
  600.   sprintf(i, "HMi%d\0", ID);
  601.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  602.   set->setPoolSize(1);
  603.   set->setMaterialName("Examples/IndicatorH");
  604.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  605.   set->setVisibilityFlags(MINIMAP_MASK);
  606.   me->setDimensions(size_indicator, size_indicator);
  607.   H_Magi::mUnit->attachObject(set);
  608.  
  609.  
  610.   //health bar
  611.   char health[8];
  612.   sprintf(health, "HMhp%d\0", ID);
  613.   H_Magi::hpSet = mSceneMgr->createBillboardSet(health);
  614.   hpSet->setPoolSize(1);
  615.   hpSet->setMaterialName("Examples/HP");
  616.   Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
  617.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  618.   H_Magi::mUnit->attachObject(hpSet);
  619.  
  620.   
  621.   //spell particles
  622.   char spell[10];
  623.   sprintf(spell, "HMsp%d\0", ID);
  624.   H_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
  625.   H_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
  626.   sprintf(spell, "HMsp%dN", ID);
  627.   H_Magi::psNode = H_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
  628.   H_Magi::psNode->attachObject(H_Magi::ps);
  629.   H_Magi::psNode->translate(0,1,0);
  630.   H_Magi::psNode->pitch(Ogre::Degree(-90));
  631.   H_Magi::psNode->lookAt(H_Magi::mDirection,Ogre::Node::TS_WORLD);
  632.   H_Magi::ps->setVisible(false);
  633.   H_Magi::spellDir = Ogre::Vector3::ZERO;
  634.  
  635.   //build decal
  636.   dec = new TerrainDecal(Ogre::String(H_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  637.   dec->hide();
  638.  
  639.   //start cooldown timer
  640.   H_Magi::cdTimer.reset(); proximityToken = NULL;
  641. }
  642.  
  643. H_Magi::H_Magi(){};
  644.  
  645. O_Brute::O_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  646.   curTargetWeight = -1;
  647.   //initialize character settings
  648.   O_Brute::damage = BRUTE_DAMAGE;
  649.   O_Brute::walkSpeed = BRUTE_WALKSPEED;
  650.   O_Brute::health = BRUTE_HEALTH;
  651.   O_Brute::attackSpeed = BRUTE_ATTACKSPEED;
  652.   O_Brute::attackRange = BRUTE_ATTACKRANGE;
  653.   O_Brute::isAttacking = false;
  654.   O_Brute::moving = 0;
  655.   O_Brute::selected = false;
  656.  
  657.   targetBarracks = NULL;
  658.   targetUnit = NULL;
  659.  
  660.   //create entity
  661.   sprintf(O_Brute::name, "OB%d", ID);  
  662.  
  663.   O_Brute::mEntity = mSceneMgr->createEntity(O_Brute::name, "goblin_warrior.MESH");
  664.   O_Brute::mEntity->setQueryFlags(ORC_MASK);
  665.   O_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  666.  
  667.   //BONE ANIMATION SETUP
  668.   Ogre::SkeletonInstance* pSK = O_Brute::mEntity->getSkeleton();
  669.   pSK->addLinkedSkeletonAnimationSource("O_BRUTE/idle.SKELETON");
  670.   pSK->addLinkedSkeletonAnimationSource("O_BRUTE/Run.SKELETON");
  671.   pSK->addLinkedSkeletonAnimationSource("O_BRUTE/Rslash1.SKELETON");
  672.  
  673.   //STORE THE ANIMATIONS
  674.   Ogre::AnimationStateSet* pass = O_Brute::mEntity->getAllAnimationStates();
  675.   pass->removeAllAnimationStates();
  676.   pass->createAnimationState("idle", 0, 6.2);
  677.   pass->createAnimationState("Run", 0, 4.26);
  678.   pass->createAnimationState("Rslash1", 0, 6.53);
  679.  
  680.  
  681.   //set animation
  682.   O_Brute::mAnimationState = O_Brute::mEntity->getAnimationState("idle");
  683.   O_Brute::mAnimationState->setLoop(true);
  684.   O_Brute::mAnimationState->setEnabled(true);
  685.  
  686.   //create this unit's sceneNode
  687.   O_Brute::mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(O_Brute::name), pos);
  688.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  689.   ent->attachObject(O_Brute::mEntity);
  690.   ent->setScale(scale);
  691.   ent->setOrientation(rot);
  692.   
  693.  
  694.  
  695.   
  696.   //minimap indicator 0426-abe
  697.   char i[7];
  698.   sprintf(i, "OBi%d\0", ID);
  699.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  700.   set->setPoolSize(1);
  701.   set->setMaterialName("Examples/IndicatorO");
  702.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  703.   set->setVisibilityFlags(MINIMAP_MASK);
  704.   me->setDimensions(size_indicator, size_indicator);
  705.   O_Brute::mUnit->attachObject(set);
  706.  
  707.  
  708.   //health bar
  709.   char health[8];
  710.   sprintf(health, "OBhp%d\0", ID);
  711.   O_Brute::hpSet = mSceneMgr->createBillboardSet(health);
  712.   hpSet->setPoolSize(1);
  713.   hpSet->setMaterialName("Examples/HP");
  714.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  715.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  716.   O_Brute::mUnit->attachObject(hpSet);
  717.  
  718.  
  719.   //build decal
  720.   dec = new TerrainDecal(Ogre::String(O_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  721.   dec->hide();
  722.  
  723.     //start cooldown timer
  724.   O_Brute::cdTimer.reset(); proximityToken = NULL;
  725. }
  726.  
  727. O_Brute::O_Brute(){};
  728.  
  729. O_Scout::O_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  730.   curTargetWeight = -1;
  731.   //initialize character settings
  732.   O_Scout::damage = SCOUT_DAMAGE;
  733.   O_Scout::walkSpeed = SCOUT_WALKSPEED;
  734.   O_Scout::health = SCOUT_HEALTH;
  735.   O_Scout::attackSpeed = SCOUT_ATTACKSPEED;
  736.   O_Scout::attackRange = SCOUT_ATTACKRANGE;
  737.   O_Scout::isAttacking = false;
  738.   O_Scout::moving = 0;
  739.   O_Scout::selected = false;
  740.  
  741.   targetBarracks = NULL;
  742.   targetUnit = NULL;
  743.  
  744.   //create entity
  745.   sprintf(O_Scout::name, "OS%d", ID);  
  746.  
  747.   O_Scout::mEntity = mSceneMgr->createEntity(O_Scout::name, "goblin_pygmy.MESH");
  748.   O_Scout::mEntity->setQueryFlags(ORC_MASK);
  749.   O_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  750.  
  751.   //BONE ANIMATION SETUP
  752.   Ogre::SkeletonInstance* pSK = O_Scout::mEntity->getSkeleton();
  753.   pSK->addLinkedSkeletonAnimationSource("O_Scout/idle.SKELETON");
  754.   pSK->addLinkedSkeletonAnimationSource("O_Scout/Run.SKELETON");
  755.   pSK->addLinkedSkeletonAnimationSource("O_Scout/Rslash1.SKELETON");
  756.  
  757.   //STORE THE ANIMATIONS
  758.   Ogre::AnimationStateSet* pass = O_Scout::mEntity->getAllAnimationStates();
  759.   pass->removeAllAnimationStates();
  760.   pass->createAnimationState("idle", 0, 6.2);
  761.   pass->createAnimationState("Run", 0, 4.26);
  762.   pass->createAnimationState("Rslash1", 0, 6.53);
  763.  
  764.  
  765.   //set animation
  766.   O_Scout::mAnimationState = O_Scout::mEntity->getAnimationState("idle");
  767.   O_Scout::mAnimationState->setLoop(true);
  768.   O_Scout::mAnimationState->setEnabled(true);
  769.  
  770.   //create this unit's sceneNode
  771.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  772.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  773.   ent->attachObject(mEntity);
  774.   ent->setScale(scale);
  775.   ent->setOrientation(rot);
  776.  
  777.   //minimap indicator 0426-abe
  778.  
  779.   char i[7];
  780.   sprintf(i, "OSi%d\0", ID);
  781.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  782.   set->setPoolSize(1);
  783.   set->setMaterialName("Examples/IndicatorO");
  784.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  785.   set->setVisibilityFlags(MINIMAP_MASK);
  786.   me->setDimensions(size_indicator, size_indicator);
  787.   O_Scout::mUnit->attachObject(set);
  788.  
  789.  
  790.   //health bar
  791.   char health[8];
  792.   sprintf(health, "OShp%d\0", ID);
  793.   O_Scout::hpSet = mSceneMgr->createBillboardSet(health);
  794.   hpSet->setPoolSize(1);
  795.   hpSet->setMaterialName("Examples/HP");
  796.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  797.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  798.   O_Scout::mUnit->attachObject(hpSet);
  799.  
  800.  
  801.   //build decal
  802.   dec = new TerrainDecal(Ogre::String(O_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  803.   dec->hide();
  804.  
  805.   //start cooldown timer
  806.   O_Scout::cdTimer.reset(); proximityToken = NULL;
  807. }
  808.  
  809. O_Scout::O_Scout(){};
  810.  
  811. O_Ranged::O_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  812.   curTargetWeight = -1;
  813.   //initialize character settings
  814.   O_Ranged::damage = RANGED_DAMAGE;
  815.   O_Ranged::walkSpeed = RANGED_WALKSPEED;
  816.   O_Ranged::health = RANGED_HEALTH;
  817.   O_Ranged::attackSpeed = RANGED_ATTACKSPEED;
  818.   O_Ranged::attackRange = RANGED_ATTACKRANGE;
  819.   O_Ranged::isAttacking = false;
  820.   O_Ranged::moving = 0;
  821.   O_Ranged::selected = false;
  822.  
  823.   targetBarracks = NULL;
  824.   targetUnit = NULL;
  825.  
  826.   //create entity
  827.   sprintf(O_Ranged::name, "OR%d", ID);  
  828.  
  829.   O_Ranged::mEntity = mSceneMgr->createEntity(O_Ranged::name, "goblin_archer.MESH");
  830.   O_Ranged::mEntity->setQueryFlags(ORC_MASK);
  831.   O_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  832.  
  833.   //BONE ANIMATION SETUP
  834.   Ogre::SkeletonInstance* pSK = O_Ranged::mEntity->getSkeleton();
  835.   pSK->addLinkedSkeletonAnimationSource("O_Ranged/Idle.SKELETON");
  836.   pSK->addLinkedSkeletonAnimationSource("O_Ranged/Run.SKELETON");
  837.   pSK->addLinkedSkeletonAnimationSource("O_Ranged/Bow.SKELETON");
  838.  
  839.   //STORE THE ANIMATIONS
  840.   Ogre::AnimationStateSet* pass = O_Ranged::mEntity->getAllAnimationStates();
  841.   pass->removeAllAnimationStates();
  842.   pass->createAnimationState("Idle", 0, 6.2);
  843.   pass->createAnimationState("Run", 0, 4.26);
  844.   pass->createAnimationState("Bow", 0, 6.53);
  845.  
  846.  
  847.   //set animation
  848.   O_Ranged::mAnimationState = O_Ranged::mEntity->getAnimationState("Idle");
  849.   O_Ranged::mAnimationState->setLoop(true);
  850.   O_Ranged::mAnimationState->setEnabled(true);
  851.  
  852.   //create this unit's sceneNode
  853.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  854.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  855.   ent->attachObject(mEntity);
  856.   ent->setScale(scale);
  857.   ent->setOrientation(rot);
  858.  
  859.   //minimap indicator 0426-abe
  860.  
  861.   char i[7];
  862.   sprintf(i, "ORi%d\0", ID);
  863.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  864.   set->setPoolSize(1);
  865.   set->setMaterialName("Examples/IndicatorO");
  866.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  867.   set->setVisibilityFlags(MINIMAP_MASK);
  868.   me->setDimensions(size_indicator, size_indicator);
  869.   O_Ranged::mUnit->attachObject(set);
  870.  
  871.  
  872.   //health bar
  873.   char health[8];
  874.   sprintf(health, "ORhp%d\0", ID);
  875.   O_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
  876.   hpSet->setPoolSize(1);
  877.   hpSet->setMaterialName("Examples/HP");
  878.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  879.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  880.   O_Ranged::mUnit->attachObject(hpSet);
  881.  
  882.  
  883.   //build decal
  884.   dec = new TerrainDecal(Ogre::String(O_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  885.   dec->hide();
  886.  
  887.   //start cooldown timer
  888.   O_Ranged::cdTimer.reset(); proximityToken = NULL;
  889. }
  890.  
  891. O_Ranged::O_Ranged(){};
  892.  
  893. O_Magi::O_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  894.   curTargetWeight = -1;
  895.   //initialize character settings
  896.   O_Magi::damage = MAGI_DAMAGE;
  897.   O_Magi::walkSpeed = MAGI_WALKSPEED;
  898.   O_Magi::health = MAGI_HEALTH;
  899.   O_Magi::attackSpeed = MAGI_ATTACKSPEED;
  900.   O_Magi::attackRange = MAGI_ATTACKRANGE;
  901.   O_Magi::isAttacking = false;
  902.   O_Magi::moving = 0;
  903.   O_Magi::selected = false;
  904.  
  905.   targetBarracks = NULL;
  906.   targetUnit = NULL;
  907.  
  908.   //create entity
  909.   sprintf(O_Magi::name, "OM%d", ID);  
  910.  
  911.   O_Magi::mEntity = mSceneMgr->createEntity(O_Magi::name, "Goblin_Healer.MESH");
  912.   O_Magi::mEntity->setQueryFlags(ORC_MASK);
  913.   O_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  914.  
  915.   //BONE ANIMATION SETUP
  916.   Ogre::SkeletonInstance* pSK = O_Magi::mEntity->getSkeleton();
  917.   pSK->addLinkedSkeletonAnimationSource("O_Magi/Idle.SKELETON");
  918.   pSK->addLinkedSkeletonAnimationSource("O_Magi/Run.SKELETON");
  919.   pSK->addLinkedSkeletonAnimationSource("O_Magi/Wand1.SKELETON");
  920.   pSK->addLinkedSkeletonAnimationSource("O_Magi/Cast_Omni.SKELETON");
  921.  
  922.   //STORE THE ANIMATIONS
  923.   Ogre::AnimationStateSet* pass = O_Magi::mEntity->getAllAnimationStates();
  924.   pass->removeAllAnimationStates();
  925.   pass->createAnimationState("Idle", 0, 6.2);
  926.   pass->createAnimationState("Run", 0, 4.26);
  927.   pass->createAnimationState("Wand1", 0, 6.53);
  928.   pass->createAnimationState("Cast_Omni", 0, 6.53);
  929.  
  930.  
  931.   //set animation
  932.   O_Magi::mAnimationState = O_Magi::mEntity->getAnimationState("Idle");
  933.   O_Magi::mAnimationState->setLoop(true);
  934.   O_Magi::mAnimationState->setEnabled(true);
  935.  
  936.   //create this unit's sceneNode
  937.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  938.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  939.   ent->attachObject(mEntity);
  940.   ent->setScale(scale);
  941.   ent->setOrientation(rot);
  942.  
  943.   //minimap indicator 0426-abe
  944.  
  945.   char i[7];
  946.   sprintf(i, "OMi%d\0", ID);
  947.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  948.   set->setPoolSize(1);
  949.   set->setMaterialName("Examples/IndicatorO");
  950.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  951.   set->setVisibilityFlags(MINIMAP_MASK);
  952.   me->setDimensions(size_indicator, size_indicator);
  953.   O_Magi::mUnit->attachObject(set);
  954.  
  955.  
  956.   //health bar
  957.   char health[8];
  958.   sprintf(health, "OMhp%d\0", ID);
  959.   O_Magi::hpSet = mSceneMgr->createBillboardSet(health);
  960.   hpSet->setPoolSize(1);
  961.   hpSet->setMaterialName("Examples/HP");
  962.   Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
  963.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  964.   O_Magi::mUnit->attachObject(hpSet);
  965.  
  966.   
  967.   //spell particles
  968.   char spell[10];
  969.   sprintf(spell, "OMsp%d\0", ID);
  970.   O_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
  971.   O_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
  972.   sprintf(spell, "OMsp%dN", ID);
  973.   O_Magi::psNode = O_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
  974.   O_Magi::psNode->attachObject(O_Magi::ps);
  975.   O_Magi::psNode->translate(0,1,0);
  976.   O_Magi::psNode->pitch(Ogre::Degree(-90));
  977.   O_Magi::psNode->lookAt(O_Magi::mDirection,Ogre::Node::TS_WORLD);
  978.   O_Magi::ps->setVisible(false);
  979.   O_Magi::spellDir = Ogre::Vector3::ZERO;
  980.  
  981.   //build decal
  982.   dec = new TerrainDecal(Ogre::String(O_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  983.   dec->hide();
  984.  
  985.   //start cooldown timer
  986.   O_Magi::cdTimer.reset(); proximityToken = NULL;
  987. }
  988.  
  989. O_Magi::O_Magi(){};
  990.  
  991. U_Brute::U_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  992.   curTargetWeight = -1;
  993.   //initialize character settings
  994.   U_Brute::damage = BRUTE_DAMAGE;
  995.   U_Brute::walkSpeed = BRUTE_WALKSPEED;
  996.   U_Brute::health = BRUTE_HEALTH;
  997.   U_Brute::attackSpeed = BRUTE_ATTACKSPEED;
  998.   U_Brute::attackRange = BRUTE_ATTACKRANGE;
  999.   U_Brute::isAttacking = false;
  1000.   U_Brute::moving = 0;
  1001.   U_Brute::selected = false;
  1002.  
  1003.   targetBarracks = NULL;
  1004.   targetUnit = NULL;
  1005.  
  1006.   //2,20,Walk1
  1007.   //22,36,Walk2
  1008.   //38,47,Defense1 
  1009.   //48,57,Defense2
  1010.   //59,75,Die1
  1011.   //78,88,Twitch
  1012.   //91,103,Die2
  1013.   //106,115,Kick
  1014.   //117,128,Punch
  1015.   //129,136,HeadButt
  1016.   //137,169,Idle1
  1017.   //170,200,Idle2
  1018.  
  1019.   //create entity
  1020.   sprintf(U_Brute::name, "UB%d", ID);  
  1021.   U_Brute::mEntity = mSceneMgr->createEntity(U_Brute::name, "zombie.mesh");
  1022.   U_Brute::mEntity->setQueryFlags(UNDEAD_MASK);
  1023.  
  1024.   //BONE ANIMATION SETUP
  1025.   Ogre::SkeletonInstance* pSK = U_Brute::mEntity->getSkeleton();
  1026.   pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Idle.SKELETON");
  1027.   pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Walk.SKELETON");
  1028.   pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Hit.SKELETON");
  1029.  
  1030.   //STORE THE ANIMATIONS
  1031.   Ogre::AnimationStateSet* pass = U_Brute::mEntity->getAllAnimationStates();
  1032.   pass->removeAllAnimationStates();
  1033.   pass->createAnimationState("Idle", 0, 6.2);
  1034.   pass->createAnimationState("Walk", 0, 4.26);
  1035.   pass->createAnimationState("Hit", 0, 6.53);
  1036.  
  1037.   //set animation
  1038.   U_Brute::mAnimationState = U_Brute::mEntity->getAnimationState("Idle");
  1039.   U_Brute::mAnimationState->setLoop(true);
  1040.   U_Brute::mAnimationState->setEnabled(true);
  1041.  
  1042.   //create this unit's sceneNode
  1043.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  1044.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  1045.   ent->attachObject(mEntity);
  1046.   ent->setScale(scale);
  1047.   ent->setOrientation(rot);
  1048.  
  1049.  
  1050.  
  1051.  
  1052.   //minimap indicator 0426-abe
  1053.   char i[7];
  1054.   sprintf(i, "UBi%d\0", ID);
  1055.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  1056.   set->setPoolSize(1);
  1057.   set->setMaterialName("Examples/IndicatorU");
  1058.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  1059.   set->setVisibilityFlags(MINIMAP_MASK);
  1060.   me->setDimensions(size_indicator, size_indicator);
  1061.   U_Brute::mUnit->attachObject(set);
  1062.  
  1063.  
  1064.   //health bar
  1065.   char health[8];
  1066.   sprintf(health, "UBhp%d\0", ID);
  1067.   U_Brute::hpSet = mSceneMgr->createBillboardSet(health);
  1068.   hpSet->setPoolSize(1);
  1069.   hpSet->setMaterialName("Examples/HP");
  1070.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  1071.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  1072.   U_Brute::mUnit->attachObject(hpSet);
  1073.  
  1074.  
  1075.   //build decal
  1076.   dec = new TerrainDecal(Ogre::String(U_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  1077.   dec->hide();
  1078.  
  1079.   //start cooldown timer
  1080.   U_Brute::cdTimer.reset(); proximityToken = NULL;
  1081. }
  1082.  
  1083. U_Brute::U_Brute(){};
  1084.  
  1085.  
  1086. U_Scout::U_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  1087.   curTargetWeight = -1;
  1088.   //initialize character settings
  1089.   U_Scout::damage = SCOUT_DAMAGE;
  1090.   U_Scout::walkSpeed = SCOUT_WALKSPEED;
  1091.   U_Scout::health = SCOUT_HEALTH;
  1092.   U_Scout::attackSpeed = SCOUT_ATTACKSPEED;
  1093.   U_Scout::attackRange = SCOUT_ATTACKRANGE;
  1094.   U_Scout::isAttacking = false;
  1095.   U_Scout::moving = 0;
  1096.   U_Scout::selected = false;
  1097.  
  1098.   targetBarracks = NULL;
  1099.   targetUnit = NULL;
  1100.  
  1101.   //create entity
  1102.   sprintf(U_Scout::name, "US%d", ID);  
  1103.   U_Scout::mEntity = mSceneMgr->createEntity(U_Scout::name, "zombiB.mesh");
  1104.   U_Scout::mEntity->setQueryFlags(UNDEAD_MASK);
  1105.  
  1106.   //set animation
  1107.   U_Scout::mAnimationState = U_Scout::mEntity->getAnimationState("Idle1");
  1108.   U_Scout::mAnimationState->setLoop(true);
  1109.   U_Scout::mAnimationState->setEnabled(true);
  1110.  
  1111.   //create this unit's sceneNode
  1112.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  1113.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  1114.   ent->attachObject(mEntity);
  1115.   ent->setScale(scale);
  1116.   ent->setOrientation(rot);
  1117.  
  1118.  
  1119.  
  1120.   //minimap indicator 0426-abe
  1121.   char i[7];
  1122.   sprintf(i, "USi%d\0", ID);
  1123.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  1124.   set->setPoolSize(1);
  1125.   set->setMaterialName("Examples/IndicatorU");
  1126.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  1127.   set->setVisibilityFlags(MINIMAP_MASK);
  1128.   me->setDimensions(size_indicator, size_indicator);
  1129.   U_Scout::mUnit->attachObject(set);
  1130.  
  1131.  
  1132.   //health bar
  1133.   char health[8];
  1134.   sprintf(health, "UShp%d\0", ID);
  1135.   U_Scout::hpSet = mSceneMgr->createBillboardSet(health);
  1136.   hpSet->setPoolSize(1);
  1137.   hpSet->setMaterialName("Examples/HP");
  1138.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  1139.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  1140.   U_Scout::mUnit->attachObject(hpSet);
  1141.  
  1142.  
  1143.   //build decal
  1144.   dec = new TerrainDecal(Ogre::String(U_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  1145.   dec->hide();
  1146.  
  1147.   //start cooldown timer
  1148.   U_Scout::cdTimer.reset(); proximityToken = NULL;
  1149. }
  1150.  
  1151. U_Scout::U_Scout(){};
  1152.  
  1153. U_Ranged::U_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  1154.   curTargetWeight = -1;
  1155.   //initialize character settings
  1156.   U_Ranged::damage = RANGED_DAMAGE;
  1157.   U_Ranged::walkSpeed = RANGED_WALKSPEED;
  1158.   U_Ranged::health = RANGED_HEALTH;
  1159.   U_Ranged::attackSpeed = RANGED_ATTACKSPEED;
  1160.   U_Ranged::attackRange = RANGED_ATTACKRANGE;
  1161.   U_Ranged::isAttacking = false;
  1162.   U_Ranged::moving = 0;
  1163.   U_Ranged::selected = false;
  1164.  
  1165.   targetBarracks = NULL;
  1166.   targetUnit = NULL;
  1167.  
  1168.   //create entity
  1169.   sprintf(U_Ranged::name, "UR%d", ID);  
  1170.  
  1171.   U_Ranged::mEntity = mSceneMgr->createEntity(U_Ranged::name, "skeleton_unarmed.MESH");
  1172.   U_Ranged::mEntity->setQueryFlags(UNDEAD_MASK);
  1173.   U_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  1174.  
  1175.   //BONE ANIMATION SETUP
  1176.   Ogre::SkeletonInstance* pSK = U_Ranged::mEntity->getSkeleton();
  1177.   pSK->addLinkedSkeletonAnimationSource("U_Ranged/Idle_Unarmed.SKELETON");
  1178.   pSK->addLinkedSkeletonAnimationSource("U_Ranged/Run_Unarmed.SKELETON");
  1179.   pSK->addLinkedSkeletonAnimationSource("U_Ranged/Bow2.SKELETON");
  1180.  
  1181.   //STORE THE ANIMATIONS
  1182.   Ogre::AnimationStateSet* pass = U_Ranged::mEntity->getAllAnimationStates();
  1183.   pass->removeAllAnimationStates();
  1184.   pass->createAnimationState("Idle_Unarmed", 0, 6.2);
  1185.   pass->createAnimationState("Run_Unarmed", 0, 4.26);
  1186.   pass->createAnimationState("Bow2", 0, 6.53);
  1187.  
  1188.  
  1189.   //set animation
  1190.   U_Ranged::mAnimationState = U_Ranged::mEntity->getAnimationState("Idle_Unarmed");
  1191.   U_Ranged::mAnimationState->setLoop(true);
  1192.   U_Ranged::mAnimationState->setEnabled(true);
  1193.  
  1194.   //create this unit's sceneNode
  1195.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  1196.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  1197.   ent->attachObject(mEntity);
  1198.   ent->setScale(scale);
  1199.   ent->setOrientation(rot);
  1200.  
  1201.   //minimap indicator 0426-abe
  1202.  
  1203.   char i[7];
  1204.   sprintf(i, "URi%d\0", ID);
  1205.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  1206.   set->setPoolSize(1);
  1207.   set->setMaterialName("Examples/IndicatorU");
  1208.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  1209.   set->setVisibilityFlags(MINIMAP_MASK);
  1210.   me->setDimensions(size_indicator, size_indicator);
  1211.   U_Ranged::mUnit->attachObject(set);
  1212.  
  1213.  
  1214.   //health bar
  1215.   char health[8];
  1216.   sprintf(health, "URhp%d\0", ID);
  1217.   U_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
  1218.   hpSet->setPoolSize(1);
  1219.   hpSet->setMaterialName("Examples/HP");
  1220.   Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
  1221.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  1222.   U_Ranged::mUnit->attachObject(hpSet);
  1223.  
  1224.  
  1225.   //build decal
  1226.   dec = new TerrainDecal(Ogre::String(U_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  1227.   dec->hide();
  1228.  
  1229.   //start cooldown timer
  1230.   U_Ranged::cdTimer.reset(); proximityToken = NULL;
  1231. }
  1232.  
  1233. U_Ranged::U_Ranged(){};
  1234.  
  1235. U_Magi::U_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
  1236.   curTargetWeight = -1;
  1237.   //initialize character settings
  1238.   U_Magi::damage = MAGI_DAMAGE;
  1239.   U_Magi::walkSpeed = MAGI_WALKSPEED;
  1240.   U_Magi::health = MAGI_HEALTH;
  1241.   U_Magi::attackSpeed = MAGI_ATTACKSPEED;
  1242.   U_Magi::attackRange = MAGI_ATTACKRANGE;
  1243.   U_Magi::isAttacking = false;
  1244.   U_Magi::moving = 0;
  1245.   U_Magi::selected = false;
  1246.  
  1247.   targetBarracks = NULL;
  1248.   targetUnit = NULL;
  1249.  
  1250.   //create entity
  1251.   sprintf(U_Magi::name, "UM%d", ID);  
  1252.  
  1253.   U_Magi::mEntity = mSceneMgr->createEntity(U_Magi::name, "Disciple.MESH");
  1254.   U_Magi::mEntity->setQueryFlags(UNDEAD_MASK);
  1255.   U_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
  1256.  
  1257.   //BONE ANIMATION SETUP
  1258.   Ogre::SkeletonInstance* pSK = U_Magi::mEntity->getSkeleton();
  1259.   pSK->addLinkedSkeletonAnimationSource("U_Magi/Idle.SKELETON");
  1260.   pSK->addLinkedSkeletonAnimationSource("U_Magi/Run.SKELETON");
  1261.   pSK->addLinkedSkeletonAnimationSource("U_Magi/Rwand1.SKELETON");
  1262.   pSK->addLinkedSkeletonAnimationSource("U_Magi/Special_Gen_Cast.SKELETON");
  1263.  
  1264.   //STORE THE ANIMATIONS
  1265.   Ogre::AnimationStateSet* pass = U_Magi::mEntity->getAllAnimationStates();
  1266.   pass->removeAllAnimationStates();
  1267.   pass->createAnimationState("Idle", 0, 6.2);
  1268.   pass->createAnimationState("Run", 0, 4.26);
  1269.   pass->createAnimationState("Rwand1", 0, 6.53);
  1270.   pass->createAnimationState("Special_Gen_Cast", 0, 6.53);
  1271.  
  1272.  
  1273.   //set animation
  1274.   U_Magi::mAnimationState = U_Magi::mEntity->getAnimationState("Idle");
  1275.   U_Magi::mAnimationState->setLoop(true);
  1276.   U_Magi::mAnimationState->setEnabled(true);
  1277.  
  1278.   //create this unit's sceneNode
  1279.   mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
  1280.   Ogre::SceneNode* ent = mUnit->createChildSceneNode();
  1281.   ent->attachObject(mEntity);
  1282.   ent->setScale(scale);
  1283.   ent->setOrientation(rot);
  1284.  
  1285.   //minimap indicator 0426-abe
  1286.  
  1287.   char i[7];
  1288.   sprintf(i, "UMi%d\0", ID);
  1289.   Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
  1290.   set->setPoolSize(1);
  1291.   set->setMaterialName("Examples/IndicatorO");
  1292.   Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
  1293.   set->setVisibilityFlags(MINIMAP_MASK);
  1294.   me->setDimensions(size_indicator, size_indicator);
  1295.   U_Magi::mUnit->attachObject(set);
  1296.  
  1297.  
  1298.   //health bar
  1299.   char health[8];
  1300.   sprintf(health, "UMhp%d\0", ID);
  1301.   U_Magi::hpSet = mSceneMgr->createBillboardSet(health);
  1302.   hpSet->setPoolSize(1);
  1303.   hpSet->setMaterialName("Examples/HP");
  1304.   Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
  1305.   hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
  1306.   U_Magi::mUnit->attachObject(hpSet);
  1307.  
  1308.   //spell particles
  1309.   char spell[10];
  1310.   sprintf(spell, "UMsp%d\0", ID);
  1311.   U_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
  1312.   U_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
  1313.   sprintf(spell, "UMsp%dN", ID);
  1314.   U_Magi::psNode = U_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
  1315.   U_Magi::psNode->attachObject(U_Magi::ps);
  1316.   U_Magi::psNode->translate(0,1,0);
  1317.   U_Magi::psNode->pitch(Ogre::Degree(-90));
  1318.   U_Magi::psNode->lookAt(U_Magi::mDirection,Ogre::Node::TS_WORLD);
  1319.   U_Magi::ps->setVisible(false);
  1320.   U_Magi::spellDir = Ogre::Vector3::ZERO;
  1321.  
  1322.  
  1323.   //build decal
  1324.   dec = new TerrainDecal(Ogre::String(U_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
  1325.   dec->hide();
  1326.  
  1327.   //start cooldown timer
  1328.   U_Magi::cdTimer.reset(); proximityToken = NULL;
  1329. }
  1330.  
  1331. U_Magi::U_Magi(){};
  1332.  
  1333.  
  1334. //UNIT COMMAND FUNCTIONS
  1335.  
  1336. void Unit::initializeMovement(Ogre::Vector3 dest){
  1337.   Unit::mDestination = dest;
  1338.   Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
  1339.   Unit::mDistance = Unit::mDirection.normalise();
  1340.   Unit::mDistance = Unit::mDistance*Unit::mDistance;
  1341.   //align the orientation for specific models
  1342.   Unit::setAnimation_Orientation();
  1343.  
  1344.   //remove the y-axis rotation to keep models standing straight
  1345.   Unit::src.y = 0;
  1346.   Unit::mDirection.y = 0;
  1347.  
  1348.   if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
  1349.   {
  1350.     Unit::mUnit->yaw(Ogre::Degree(180));
  1351.   }
  1352.   else
  1353.   {
  1354.     Ogre::Quaternion quat = Unit::src.getRotationTo(Unit::mDirection);
  1355.     Unit::mUnit->rotate(quat);
  1356.   } // else
  1357.  
  1358.   //get animation
  1359.   setAnimation_Walk();
  1360.  
  1361.   //change status so the units actually move.
  1362.   Unit::moving = 1;
  1363. }
  1364.  
  1365.  
  1366. bool Unit::setTarget(Barracks *target, Ogre::Real w){
  1367.   if(target->controlRace != Unit::name[0]){
  1368.     Unit::isAttacking = true; //set my attack mode to true
  1369.     Unit::targetBarracks = target; //and assign the taget name so updateAnimations() can operate
  1370.     Unit::curTargetWeight = w;
  1371.   }
  1372.   else{
  1373.     return false;
  1374.   }
  1375.   return true;
  1376. }
  1377. bool Unit::setTarget(Unit *target, Ogre::Real w){
  1378.   if(target != NULL)
  1379.   {
  1380.     if(target->name[0] != Unit::name[0]){
  1381.       Unit::isAttacking = true; //set my attack mode to true
  1382.       Unit::targetUnit = target; //and assign the taget name so updateAnimations() can operate
  1383.       Unit::curTargetWeight = w;
  1384.       return true;
  1385.     }
  1386.     else{
  1387.       return false;
  1388.     }
  1389.   }
  1390.   else
  1391.   {
  1392.     return false;
  1393.   }
  1394.  
  1395. }
  1396.  
  1397. Unit::~Unit()
  1398. {
  1399.   Unit::dec->~TerrainDecal();
  1400. }
  1401.  
  1402. void Unit::removeTarget(){
  1403.   Unit::isAttacking = false; //set my attack mode to false
  1404.   Unit::targetUnit = NULL; //and nullify my target
  1405.   Unit::targetBarracks = NULL; //and nullify my target
  1406.   Unit::setAnimation_Idle(); //set animation to Idle as well
  1407. }
  1408.  
  1409. void Unit::targetBarrDestroyed(){
  1410.   //destroy tower
  1411.   if(targetBarracks->hasTower)
  1412.   {
  1413.     //hide tower
  1414.     targetBarracks->mTower->setVisible(false);
  1415.     targetBarracks->maxHealth = 500;
  1416.     targetBarracks->hasTower = false;
  1417.   }
  1418.  
  1419.   targetBarracks->controlRace = Unit::name[0];
  1420.   targetBarracks->health = 500;
  1421.   targetBarracks->hpSet->getBillboard(0)->setDimensions(BARRACK_HP_SIZE_X,BARRACK_HP_SIZE_Y);
  1422.   Ogre::String raceT;
  1423.   raceT = targetBarracks->controlRace;      
  1424.   targetBarracks->mEntity->setMaterialName("barrack"+ raceT +"/kosciol");
  1425.   targetBarracks->dec->setMaterial("Examples/SelectorRingG");
  1426.   Ogre::String temp = targetBarracks->name;
  1427.   targetBarracks->wasReset = true;
  1428.   targetBarracks->SFireSet = false;
  1429.   targetBarracks->MFireSet = false;
  1430.   targetBarracks->LFireSet = false;
  1431.   Ogre::String tempie;
  1432.   tempie = targetBarracks->controlRace;
  1433.   targetBarracks->MinimapSet->setMaterialName("Examples/Indicator"+tempie);
  1434.  
  1435.   if(Unit::name[1] == 'M'){
  1436.     switch(Unit::name[0]){
  1437.       case 'O':
  1438.         ((O_Magi*)this)->ps->setVisible(false);
  1439.         break;
  1440.  
  1441.       case 'U':
  1442.         ((U_Magi*)this)->ps->setVisible(false);
  1443.         break;
  1444.       case 'H':
  1445.         ((H_Magi*)this)->ps->setVisible(false);
  1446.         break;
  1447.       case 'C':
  1448.         ((C_Magi*)this)->ps->setVisible(false);
  1449.         break;
  1450.     }
  1451.   }
  1452. }
  1453.  
  1454. void Unit::targetUnitDestroyed(){
  1455.  
  1456.   targetUnit->health = 0;
  1457.   targetUnit->hpSet->getBillboard(0)->setDimensions(0,0);
  1458.  
  1459.   targetUnit->mUnit->getAttachedObject(1)->setVisible(false);
  1460.   targetUnit->mEntity->setVisible(false);
  1461.   targetUnit->dec->hide();
  1462.  
  1463.   targetUnit->mUnit->getParentSceneNode()->removeAndDestroyChild(targetUnit->mUnit->getName());
  1464.   targetUnit->mUnit = NULL;
  1465.   
  1466.   if(Unit::name[1] == 'M'){
  1467.     switch(Unit::name[0]){
  1468.       case 'O':
  1469.         ((O_Magi*)this)->ps->setVisible(false);
  1470.         break;
  1471.  
  1472.       case 'U':
  1473.         ((U_Magi*)this)->ps->setVisible(false);
  1474.         break;
  1475.       case 'H':
  1476.         ((H_Magi*)this)->ps->setVisible(false);
  1477.         break;
  1478.       case 'C':
  1479.         ((C_Magi*)this)->ps->setVisible(false);
  1480.         break;
  1481.     }
  1482.   }
  1483.  
  1484. }
  1485.  
  1486.  
  1487. bool Unit::attackBarracks(){
  1488.   if(targetBarracks->controlRace == Unit::name[0]){
  1489.     Unit::removeTarget();
  1490.     return true;
  1491.   }
  1492.   Ogre::Real distanceBetween = Unit::mUnit->getPosition().distance(targetBarracks->mNode->getPosition());
  1493.   if(distanceBetween <= (Unit::attackRange + 25)){ //if I'm within my attack range, attack
  1494.     Unit::setAnimation_Attack(); //set animation to Attack as well
  1495.  
  1496.     //rotate the model to attack
  1497.     Unit::mDestination = targetBarracks->mNode->getPosition();
  1498.     Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
  1499.     Unit::mDistance = Unit::mDirection.normalise();
  1500.  
  1501.     //align the orientation for specific models
  1502.     Unit::setAnimation_Orientation();
  1503.  
  1504.     Ogre::Quaternion quat;
  1505.  
  1506.     //remove the y-axis rotation to keep models standing straight
  1507.     Unit::src.y = 0;
  1508.     Unit::mDirection.y = 0;
  1509.  
  1510.     if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
  1511.     {
  1512.       Unit::mUnit->yaw(Ogre::Degree(180));
  1513.     }
  1514.     else
  1515.     {
  1516.       quat = Unit::src.getRotationTo(Unit::mDirection);
  1517.       Unit::mUnit->rotate(quat);
  1518.     } // else
  1519.  
  1520.     if(Unit::mEntity->getName().substr(1,1) == "M"){
  1521.  
  1522.       Ogre::Vector3 normie;
  1523.       std::stringstream oss;
  1524.       
  1525.       switch(Unit::mEntity->getName().at(0)){
  1526.         case 'O':
  1527.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1528.             ((O_Magi*)this)->spellDir = Unit::mDirection;
  1529.           }
  1530.           ((O_Magi*)this)->psNode->rotate(quat);
  1531.           normie = ((O_Magi*)this)->spellDir;
  1532.           normie.x *= 55;
  1533.           normie.y = 0;
  1534.           normie.z *= 55;
  1535.           oss << normie.x << " " << normie.y << " " << normie.z;
  1536.           ((O_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1537.           ((O_Magi*)this)->ps->getEmitter(0)->setDirection(((O_Magi*)this)->spellDir);
  1538.           ((O_Magi*)this)->ps->setVisible(true);
  1539.           break;
  1540.  
  1541.         case 'U':
  1542.           //((U_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
  1543.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1544.             ((U_Magi*)this)->spellDir = Unit::mDirection;
  1545.           }
  1546.           ((U_Magi*)this)->psNode->rotate(quat);
  1547.           normie = ((U_Magi*)this)->spellDir;
  1548.           normie.x *= 55;
  1549.           normie.y = 0;
  1550.           normie.z *= 55;
  1551.           oss << normie.x << " " << normie.y << " " << normie.z;
  1552.           ((U_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1553.           ((U_Magi*)this)->ps->getEmitter(0)->setDirection(((U_Magi*)this)->spellDir);
  1554.           ((U_Magi*)this)->ps->setVisible(true);
  1555.           break;
  1556.         case 'H':
  1557.           //((H_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
  1558.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1559.             ((H_Magi*)this)->spellDir = Unit::mDirection;
  1560.           }
  1561.           ((H_Magi*)this)->psNode->rotate(quat);
  1562.           normie = ((H_Magi*)this)->spellDir;
  1563.           normie.x *= 55;
  1564.           normie.y = 0;
  1565.           normie.z *= 55;
  1566.           oss << normie.x << " " << normie.y << " " << normie.z;
  1567.           ((H_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1568.           ((H_Magi*)this)->ps->getEmitter(0)->setDirection(((H_Magi*)this)->spellDir);
  1569.           ((H_Magi*)this)->ps->setVisible(true);
  1570.           break;
  1571.         case 'C':
  1572.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1573.             ((C_Magi*)this)->spellDir = Unit::mDirection;
  1574.           }
  1575.           ((C_Magi*)this)->psNode->rotate(quat);
  1576.           normie = ((C_Magi*)this)->spellDir;
  1577.           normie.x *= 10;
  1578.           normie.y = 0;
  1579.           normie.z *= 10;
  1580.           oss << normie.x << " " << normie.y << " " << normie.z;
  1581.           ((C_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1582.           ((C_Magi*)this)->ps->getEmitter(0)->setDirection(((C_Magi*)this)->spellDir);
  1583.           ((C_Magi*)this)->ps->setVisible(true);
  1584.           break;
  1585.       }
  1586.     }
  1587.  
  1588.     Unit::moving = false;
  1589.     if(Unit::cdTimer.getMilliseconds() > Unit::attackSpeed){ //if my cooldown's done..
  1590.       targetBarracks->health -= Unit::damage;
  1591.       targetBarracks->hpSet->getBillboard(0)->setDimensions(BARRACK_HP_SIZE_X*(targetBarracks->health/targetBarracks->maxHealth),BARRACK_HP_SIZE_Y);
  1592.       if(targetBarracks->health <= 0){
  1593.         Unit::targetBarrDestroyed();
  1594.         return false;
  1595.       } 
  1596.       Unit::cdTimer.reset();
  1597.     }
  1598.   }
  1599.   else{ //otherwise, walk towards my opponent
  1600.     if(Unit::mEntity->getName().substr(1,1) == "M"){
  1601.       switch(Unit::mEntity->getName().at(0)){
  1602.         case 'O':
  1603.           ((O_Magi*)this)->ps->setVisible(false);
  1604.           break;
  1605.  
  1606.         case 'U':
  1607.  
  1608.           break;
  1609.         case 'H':
  1610.  
  1611.           break;
  1612.         case 'C':
  1613.           ((C_Magi*)this)->ps->setVisible(false);
  1614.           break;
  1615.       }
  1616.     }
  1617.     Unit::initializeMovement(targetBarracks->mNode->getPosition());
  1618.   }
  1619.   return true;
  1620. }
  1621.  
  1622. bool Unit::attackUnit(){
  1623.   if((targetUnit->name[0] == Unit::name[0]) || (targetUnit->mUnit == NULL)){
  1624.     Unit::removeTarget();
  1625.     return true;
  1626.   }
  1627.   Ogre::Real distanceBetween = Unit::mUnit->getPosition().distance(targetUnit->mUnit->getPosition());
  1628.   if(distanceBetween <= Unit::attackRange){ //if I'm within my attack range, attack
  1629.     Unit::setAnimation_Attack(); //set animation to Attack as well
  1630.  
  1631.     //rotate the model to attack
  1632.     Unit::mDestination = targetUnit->mUnit->getPosition();
  1633.     Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
  1634.     Unit::mDistance = Unit::mDirection.normalise();
  1635.  
  1636.     //align the orientation for specific models
  1637.     Unit::setAnimation_Orientation();
  1638.  
  1639.     Ogre::Quaternion quat;
  1640.  
  1641.     //remove the y-axis rotation to keep models standing straight
  1642.     Unit::src.y = 0;
  1643.     Unit::mDirection.y = 0;
  1644.  
  1645.     if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
  1646.     {
  1647.       Unit::mUnit->yaw(Ogre::Degree(180));
  1648.     }
  1649.     else
  1650.     {
  1651.       quat = Unit::src.getRotationTo(Unit::mDirection);
  1652.       Unit::mUnit->rotate(quat);
  1653.     } // else
  1654.  
  1655.     if(Unit::mEntity->getName().substr(1,1) == "M"){
  1656.  
  1657.       Ogre::Vector3 normie;
  1658.       std::stringstream oss;
  1659.       
  1660.       switch(Unit::mEntity->getName().at(0)){
  1661.         case 'O':
  1662.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1663.             ((O_Magi*)this)->spellDir = Unit::mDirection;
  1664.           }
  1665.           ((O_Magi*)this)->psNode->rotate(quat);
  1666.           normie = ((O_Magi*)this)->spellDir;
  1667.           normie.x *= 55;
  1668.           normie.y = 0;
  1669.           normie.z *= 55;
  1670.           oss << normie.x << " " << normie.y << " " << normie.z;
  1671.           ((O_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1672.           ((O_Magi*)this)->ps->getEmitter(0)->setDirection(((O_Magi*)this)->spellDir);
  1673.           ((O_Magi*)this)->ps->setVisible(true);
  1674.           break;
  1675.  
  1676.         case 'U':
  1677.           //((U_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
  1678.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1679.             ((U_Magi*)this)->spellDir = Unit::mDirection;
  1680.           }
  1681.           ((U_Magi*)this)->psNode->rotate(quat);
  1682.           normie = ((U_Magi*)this)->spellDir;
  1683.           normie.x *= 55;
  1684.           normie.y = 0;
  1685.           normie.z *= 55;
  1686.           oss << normie.x << " " << normie.y << " " << normie.z;
  1687.           ((U_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1688.           ((U_Magi*)this)->ps->getEmitter(0)->setDirection(((U_Magi*)this)->spellDir);
  1689.           ((U_Magi*)this)->ps->setVisible(true);
  1690.           break;
  1691.         case 'H':
  1692.           //((H_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
  1693.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1694.             ((H_Magi*)this)->spellDir = Unit::mDirection;
  1695.           }
  1696.           ((H_Magi*)this)->psNode->rotate(quat);
  1697.           normie = ((H_Magi*)this)->spellDir;
  1698.           normie.x *= 55;
  1699.           normie.y = 0;
  1700.           normie.z *= 55;
  1701.           oss << normie.x << " " << normie.y << " " << normie.z;
  1702.           ((H_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1703.           ((H_Magi*)this)->ps->getEmitter(0)->setDirection(((H_Magi*)this)->spellDir);
  1704.           ((H_Magi*)this)->ps->setVisible(true);
  1705.           break;
  1706.         case 'C':
  1707.           if(Unit::mDirection != Ogre::Vector3::ZERO){
  1708.             ((C_Magi*)this)->spellDir = Unit::mDirection;
  1709.           }
  1710.           ((C_Magi*)this)->psNode->rotate(quat);
  1711.           normie = ((C_Magi*)this)->spellDir;
  1712.           normie.x *= 10;
  1713.           normie.y = 0;
  1714.           normie.z *= 10;
  1715.           oss << normie.x << " " << normie.y << " " << normie.z;
  1716.           ((C_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
  1717.           ((C_Magi*)this)->ps->getEmitter(0)->setDirection(((C_Magi*)this)->spellDir);
  1718.           ((C_Magi*)this)->ps->setVisible(true);
  1719.           break;
  1720.       }
  1721.     }
  1722.  
  1723.     Unit::moving = false;
  1724.     if(Unit::cdTimer.getMilliseconds() > Unit::attackSpeed){ //if my cooldown's done..
  1725.       targetUnit->health -= Unit::damage;
  1726.       int maxHealth = 0;
  1727.       switch(targetUnit->name[1]){
  1728.         case 'B':
  1729.           maxHealth = BRUTE_HEALTH;
  1730.           break;
  1731.         case 'S':
  1732.           maxHealth = SCOUT_HEALTH;
  1733.           break;
  1734.         case 'R':
  1735.           maxHealth = RANGED_HEALTH;
  1736.           break;
  1737.         case 'M':
  1738.           maxHealth = MAGI_HEALTH;
  1739.           break;
  1740.       }
  1741.       Ogre::Real tempF;
  1742.       tempF = (Ogre::Real) targetUnit->health / maxHealth;
  1743.       tempF *= HP_SIZE_X;
  1744.       targetUnit->hpSet->getBillboard(0)->setDimensions(tempF,HP_SIZE_Y);
  1745.       if(targetUnit->health <= 0){
  1746.         //Unit::targetUnitDestroyed();
  1747.         return false;
  1748.       } 
  1749.       Unit::cdTimer.reset();
  1750.     }
  1751.   }
  1752.   else{ //otherwise, walk towards my opponent
  1753.     if(Unit::mEntity->getName().substr(1,1) == "M"){
  1754.       switch(Unit::mEntity->getName().at(0)){
  1755.         case 'O':
  1756.           ((O_Magi*)this)->ps->setVisible(false);
  1757.           break;
  1758.  
  1759.         case 'U':
  1760.           //Undead not implemented
  1761.           break;
  1762.         case 'H':
  1763.           //Human not implemented
  1764.           break;
  1765.         case 'C':
  1766.           ((C_Magi*)this)->ps->setVisible(false);
  1767.           break;
  1768.       }
  1769.     }
  1770.     Unit::initializeMovement(targetUnit->mUnit->getPosition());
  1771.   }
  1772.   return true;
  1773. }
  1774.  
  1775.  
  1776. void Unit::setAnimation_Walk(){
  1777.   Ogre::String compName = Unit::mUnit->getName().substr(0,2);
  1778.   if(compName == "US"){
  1779.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Walk1");
  1780.   }
  1781.   else if(compName == "OB" || compName == "OS" || compName == "HR" || compName == "OR" || compName == "OM" || compName == "UM" || compName == "CS" || compName == "CM"){
  1782.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Run");
  1783.   }
  1784.   else if(compName == "CR"){
  1785.     Unit::mAnimationState = Unit::mEntity->getAnimationState("armed");
  1786.   }
  1787.   else if(compName == "HS"){
  1788.     Unit::mAnimationState = Unit::mEntity->getAnimationState("run");
  1789.   }
  1790.   else if(compName == "HM"){
  1791.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle");
  1792.   }
  1793.   else if(compName == "UR"){
  1794.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Run_Unarmed");
  1795.   }
  1796.   else{
  1797.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Walk");
  1798.   }
  1799.   Unit::mAnimationState->setLoop(true);
  1800.   Unit::mAnimationState->setEnabled(true);
  1801. }
  1802.  
  1803. void Unit::setAnimation_Idle(){
  1804.   // Set Idle animation 
  1805.   Ogre::String compName = Unit::mUnit->getName().substr(0,2);
  1806.   if(compName == "CB" || compName == "UB" || compName == "HR" || compName == "OR" || compName == "OM" || compName == "UM" || compName == "CS" || compName == "CM" || compName == "HM"){
  1807.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle");
  1808.   }
  1809.   else if(compName == "HB"){
  1810.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle3");
  1811.   }
  1812.   else if(compName == "US"){
  1813.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle1");
  1814.   }
  1815.   else if(compName == "OB" || compName == "OS" || compName == "HS"){
  1816.     Unit::mAnimationState = Unit::mEntity->getAnimationState("idle");
  1817.   }
  1818.   else if(compName == "UR"){
  1819.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle_Unarmed");
  1820.   }
  1821.   else if(compName == "CR"){
  1822.     Unit::mAnimationState = Unit::mEntity->getAnimationState("armed");
  1823.   }
  1824.  
  1825.   Unit::mAnimationState->setLoop(true);
  1826.   Unit::mAnimationState->setEnabled(true);
  1827. };
  1828.  
  1829. void Unit::setAnimation_Attack(){
  1830.     // Set Attack animation 
  1831.   Ogre::String compName = Unit::mUnit->getName().substr(0,2);
  1832.   if(compName == "CB"){
  1833.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Shoot");
  1834.   }
  1835.   else if(compName == "HB"){
  1836.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Attack1");
  1837.   }
  1838.   else if(compName == "US"){
  1839.     Unit::mAnimationState = Unit::mEntity->getAnimationState("HeadButt"); //Punch Kick
  1840.   }
  1841.   else if(compName == "OM"){
  1842.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Cast_Omni");
  1843.   }
  1844.   else if(compName == "UM"){
  1845.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Special_Gen_Cast");
  1846.   }
  1847.   else if(compName == "OB" || compName == "OS"){
  1848.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Rslash1");
  1849.   }
  1850.   else if(compName == "OR"){
  1851.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow");
  1852.   }
  1853.   else if(compName == "UR"){
  1854.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow2");
  1855.   }
  1856.   else if(compName == "CS"){
  1857.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Attack1");
  1858.   }
  1859.   else if(compName == "CR"){
  1860.     Unit::mAnimationState = Unit::mEntity->getAnimationState("attack");
  1861.   }
  1862.   else if(compName == "CM"){
  1863.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Special_Spray_Left");
  1864.   }
  1865.   else if(compName == "HS"){
  1866.     Unit::mAnimationState = Unit::mEntity->getAnimationState("rslash1");
  1867.   }
  1868.   else if(compName == "HM"){
  1869.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Fidget1");
  1870.   }
  1871.   else if(compName == "HR"){
  1872.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow1");
  1873.   }
  1874.   else if(compName == "UB"){
  1875.     Unit::mAnimationState = Unit::mEntity->getAnimationState("Hit");
  1876.   }
  1877.  
  1878.   Unit::mAnimationState->setLoop(true);
  1879.   Unit::mAnimationState->setEnabled(true);
  1880. };
  1881.  
  1882. void Unit::setAnimation_Orientation(){
  1883.   //align the orientation for specific models
  1884.   Ogre::String compName = Unit::mUnit->getName().substr(0,2);
  1885.   if(compName == "CB"){
  1886.     Unit::src = Unit::mUnit->getOrientation() * Ogre::Vector3::UNIT_X;
  1887.   }
  1888.   else if(compName == "HB"){
  1889.     Unit::src = Unit::mUnit->getOrientation() * -(Ogre::Vector3::UNIT_Z);
  1890.   }
  1891.   else if(compName == "UB" || compName == "US"){
  1892.     Unit::src = Unit::mUnit->getOrientation() * (Ogre::Vector3::UNIT_Z);
  1893.   }
  1894.   else if(compName == "OB" || compName == "OS" || compName == "HR" || compName == "OR" || compName == "OM" || compName == "UR" || compName == "UM" || compName == "CS" || compName == "CM" || compName == "CR" || compName == "HS" || compName == "HM"){
  1895.     Unit::src = Unit::mUnit->getOrientation() * (Ogre::Vector3::UNIT_Z);
  1896.   }
  1897. };
  1898.  
  1899.  
  1900. Ogre::Real Unit::getWeight(Unit* target){
  1901.   Ogre::Real weight = -1.0;
  1902.   if(target && this->name!=""){
  1903.     if(target->name[1] != 'b'){
  1904.       weight = (target->mUnit->getPosition()-mUnit->getPosition()).squaredLength();
  1905.       weight = 50000.0/weight - target->health+280;
  1906.       if(target->targetUnit !=NULL){
  1907.         if(target->targetUnit->name[0] == name[0]){
  1908.           weight+=150;
  1909.         }
  1910.       }
  1911.       else if(target->targetBarracks !=NULL){
  1912.         if(target->targetBarracks->name[0] == name[0]){
  1913.           weight+=200;
  1914.         }
  1915.       }
  1916.     }
  1917.   }
  1918.   
  1919.     
  1920.   return weight;
  1921. };
  1922.  
  1923.  
  1924. Ogre::Real Unit::getWeight(Barracks* target){
  1925.   Ogre::Real weight = -1.0;
  1926.  
  1927.   weight = (target->mNode->getPosition()- mUnit->getPosition()).squaredLength()/700 + target->health/2 + 150;
  1928.     
  1929.   return weight;
  1930. };
* This source code was highlighted with Source Code Highlighter.

Races and Units
OrcRace
Orcs
UndeadRace
Undead
CyborgRace
Cyborgs
HumanRace
Humans


Copyright © 2009 David Straily