- #include "Unit.h"
- #define size_indicator 40
-
- C_Brute::C_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
-
- //initialize character settings
- C_Brute::damage = BRUTE_DAMAGE;
- C_Brute::walkSpeed = BRUTE_WALKSPEED;
- C_Brute::health = BRUTE_HEALTH;
- C_Brute::attackSpeed = BRUTE_ATTACKSPEED;
- C_Brute::attackRange = BRUTE_ATTACKRANGE;
- C_Brute::isAttacking = false;
- C_Brute::moving = 0;
- C_Brute::selected = false;
- curTargetWeight = -1;
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(C_Brute::name, "CB%d", ID);
-
- C_Brute::mEntity = mSceneMgr->createEntity(C_Brute::name, "robot.mesh");
- C_Brute::mEntity->setQueryFlags(CYBORG_MASK);
- C_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
- //set animation
- C_Brute::mAnimationState = C_Brute::mEntity->getAnimationState("Idle");
- C_Brute::mAnimationState->setLoop(true);
- C_Brute::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "CBi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorC");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- C_Brute::mUnit->attachObject(set);
-
- //health box
- char health[8];
- sprintf(health, "CBhp%d\0", ID);
- C_Brute::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- hpSet->setSortingEnabled(true);
- Ogre::Billboard* hp = hpSet->createBillboard(0, 25, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- C_Brute::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(C_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- C_Brute::cdTimer.reset(); proximityToken = NULL;
- }
-
- C_Brute::C_Brute(){};
-
- C_Scout::C_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- C_Scout::damage = SCOUT_DAMAGE;
- C_Scout::walkSpeed = SCOUT_WALKSPEED;
- C_Scout::health = SCOUT_HEALTH;
- C_Scout::attackSpeed = SCOUT_ATTACKSPEED;
- C_Scout::attackRange = SCOUT_ATTACKRANGE;
- C_Scout::isAttacking = false;
- C_Scout::moving = 0;
- C_Scout::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(C_Scout::name, "CS%d", ID);
-
- C_Scout::mEntity = mSceneMgr->createEntity(C_Scout::name, "Mech_Crawler.MESH");
- C_Scout::mEntity->setQueryFlags(CYBORG_MASK);
- C_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = C_Scout::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("C_SCOUT/Attack1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = C_Scout::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Attack1", 0, 6.53);
-
- //set animation
- C_Scout::mAnimationState = C_Scout::mEntity->getAnimationState("Idle");
- C_Scout::mAnimationState->setLoop(true);
- C_Scout::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "CSi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorC");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- C_Scout::mUnit->attachObject(set);
-
- //health box
- char health[8];
- sprintf(health, "CShp%d\0", ID);
- C_Scout::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- hpSet->setSortingEnabled(true);
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- C_Scout::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(C_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- C_Scout::cdTimer.reset(); proximityToken = NULL; proximityToken = NULL;
- proximityToken = NULL;
- }
-
- C_Scout::C_Scout(){};
-
- C_Ranged::C_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- C_Ranged::damage = RANGED_DAMAGE;
- C_Ranged::walkSpeed = RANGED_WALKSPEED;
- C_Ranged::health = RANGED_HEALTH;
- C_Ranged::attackSpeed = RANGED_ATTACKSPEED;
- C_Ranged::attackRange = RANGED_ATTACKRANGE;
- C_Ranged::isAttacking = false;
- C_Ranged::moving = 0;
- C_Ranged::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(C_Ranged::name, "CR%d", ID);
-
- C_Ranged::mEntity = mSceneMgr->createEntity(C_Ranged::name, "fortress_ballista_01.MESH");
- C_Ranged::mEntity->setQueryFlags(CYBORG_MASK);
- C_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = C_Ranged::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("C_Ranged/armed.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("C_Ranged/attack.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = C_Ranged::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("armed", 0, 6.2);
- pass->createAnimationState("attack", 0, 6.53);
-
- //set animation
- C_Ranged::mAnimationState = C_Ranged::mEntity->getAnimationState("armed");
- C_Ranged::mAnimationState->setLoop(true);
- C_Ranged::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "CRi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorC");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- C_Ranged::mUnit->attachObject(set);
-
- //health box
- char health[8];
- sprintf(health, "CRhp%d\0", ID);
- C_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- hpSet->setSortingEnabled(true);
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- C_Ranged::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(C_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- C_Ranged::cdTimer.reset(); proximityToken = NULL;
- }
-
- C_Ranged::C_Ranged(){};
-
- C_Magi::C_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- C_Magi::damage = MAGI_DAMAGE;
- C_Magi::walkSpeed = MAGI_WALKSPEED;
- C_Magi::health = MAGI_HEALTH;
- C_Magi::attackSpeed = MAGI_ATTACKSPEED;
- C_Magi::attackRange = MAGI_ATTACKRANGE;
- C_Magi::isAttacking = false;
- C_Magi::moving = 0;
- C_Magi::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(C_Magi::name, "CM%d", ID);
-
- C_Magi::mEntity = mSceneMgr->createEntity(C_Magi::name, "Mech_Construct.MESH");
- C_Magi::mEntity->setQueryFlags(CYBORG_MASK);
- C_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = C_Magi::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("C_Magi/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("C_Magi/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("C_Magi/Special_Spray_Left.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = C_Magi::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Special_Spray_Left", 0, 6.53);
-
- //set animation
- C_Magi::mAnimationState = C_Magi::mEntity->getAnimationState("Idle");
- C_Magi::mAnimationState->setLoop(true);
- C_Magi::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "CMi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorC");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- C_Magi::mUnit->attachObject(set);
-
- //health box
- char health[8];
- sprintf(health, "CMhp%d\0", ID);
- C_Magi::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- hpSet->setSortingEnabled(true);
- Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- C_Magi::mUnit->attachObject(hpSet);
-
- //spell particles
- char spell[10];
- sprintf(spell, "CMsp%d\0", ID);
- C_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/chaingun");
- C_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
- sprintf(spell, "CMsp%dN", ID);
- C_Magi::psNode = C_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
- C_Magi::psNode->attachObject(C_Magi::ps);
- C_Magi::psNode->translate(0,1,0);
- C_Magi::psNode->pitch(Ogre::Degree(-90));
- C_Magi::psNode->lookAt(C_Magi::mDirection,Ogre::Node::TS_WORLD);
- C_Magi::ps->setVisible(false);
- C_Magi::spellDir = Ogre::Vector3::ZERO;
-
- //build decal
- dec = new TerrainDecal(Ogre::String(C_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- C_Magi::cdTimer.reset(); proximityToken = NULL;
- }
-
- C_Magi::C_Magi(){};
-
- H_Brute::H_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- H_Brute::damage = BRUTE_DAMAGE;
- H_Brute::walkSpeed = BRUTE_WALKSPEED;
- H_Brute::health = BRUTE_HEALTH;
- H_Brute::attackSpeed = BRUTE_ATTACKSPEED;
- H_Brute::attackRange = BRUTE_ATTACKRANGE;
- H_Brute::isAttacking = false;
- H_Brute::moving = 0;
- H_Brute::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(H_Brute::name, "HB%d", ID);
- H_Brute::mEntity = mSceneMgr->createEntity(H_Brute::name, "dwarf.mesh");
- H_Brute::mEntity->setQueryFlags(HUMAN_MASK);
- H_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //set animation
- H_Brute::mAnimationState = H_Brute::mEntity->getAnimationState("Idle1");
- H_Brute::mAnimationState->setLoop(true);
- H_Brute::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode 0502-abe
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "HBi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorH");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- H_Brute::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "HBhp%d\0", ID);
- H_Brute::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- H_Brute::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(H_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- H_Brute::cdTimer.reset(); proximityToken = NULL;
- }
-
- H_Brute::H_Brute(){};
-
- H_Scout::H_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- H_Scout::damage = SCOUT_DAMAGE;
- H_Scout::walkSpeed = SCOUT_WALKSPEED;
- H_Scout::health = SCOUT_HEALTH;
- H_Scout::attackSpeed = SCOUT_ATTACKSPEED;
- H_Scout::attackRange = SCOUT_ATTACKRANGE;
- H_Scout::isAttacking = false;
- H_Scout::moving = 0;
- H_Scout::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(H_Scout::name, "HS%d", ID);
-
- H_Scout::mEntity = mSceneMgr->createEntity(H_Scout::name, "miner.MESH");
- H_Scout::mEntity->setQueryFlags(HUMAN_MASK);
- H_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = H_Scout::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("H_Scout/idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("H_Scout/run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("H_Scout/rslash1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = H_Scout::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("idle", 0, 6.2);
- pass->createAnimationState("run", 0, 4.26);
- pass->createAnimationState("rslash1", 0, 6.53);
-
-
- //set animation
- H_Scout::mAnimationState = H_Scout::mEntity->getAnimationState("idle");
- H_Scout::mAnimationState->setLoop(true);
- H_Scout::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "HSi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorH");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- H_Scout::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "HShp%d\0", ID);
- H_Scout::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- H_Scout::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(H_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- H_Scout::cdTimer.reset(); proximityToken = NULL;
- }
-
- H_Scout::H_Scout(){};
-
- H_Ranged::H_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- H_Ranged::damage = RANGED_DAMAGE;
- H_Ranged::walkSpeed = RANGED_WALKSPEED;
- H_Ranged::health = RANGED_HEALTH;
- H_Ranged::attackSpeed = RANGED_ATTACKSPEED;
- H_Ranged::attackRange = RANGED_ATTACKRANGE;
- H_Ranged::isAttacking = false;
- H_Ranged::moving = 0;
- H_Ranged::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(H_Ranged::name, "HR%d", ID);
-
- H_Ranged::mEntity = mSceneMgr->createEntity(H_Ranged::name, "Vanquisher.MESH");
- H_Ranged::mEntity->setQueryFlags(HUMAN_MASK);
- H_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = H_Ranged::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("H_RANGED/idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("H_RANGED/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("H_RANGED/Bow1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = H_Ranged::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Bow1", 0, 6.53);
-
-
- //set animation
- H_Ranged::mAnimationState = H_Ranged::mEntity->getAnimationState("Idle");
- H_Ranged::mAnimationState->setLoop(true);
- H_Ranged::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "HRi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorH");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- H_Ranged::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "HRhp%d\0", ID);
- H_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- H_Ranged::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(H_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- H_Ranged::cdTimer.reset(); proximityToken = NULL;
- }
-
- H_Ranged::H_Ranged(){};
-
- H_Magi::H_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- H_Magi::damage = MAGI_DAMAGE;
- H_Magi::walkSpeed = MAGI_WALKSPEED;
- H_Magi::health = MAGI_HEALTH;
- H_Magi::attackSpeed = MAGI_ATTACKSPEED;
- H_Magi::attackRange = MAGI_ATTACKRANGE;
- H_Magi::isAttacking = false;
- H_Magi::moving = 0;
- H_Magi::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(H_Magi::name, "HM%d", ID);
-
- H_Magi::mEntity = mSceneMgr->createEntity(H_Magi::name, "mage.MESH");
- H_Magi::mEntity->setQueryFlags(HUMAN_MASK);
- H_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = H_Magi::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("H_Magi/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("H_Magi/Fidget1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = H_Magi::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Fidget1", 0, 6.26);
-
- //set animation
- H_Magi::mAnimationState = H_Magi::mEntity->getAnimationState("Idle");
- H_Magi::mAnimationState->setLoop(true);
- H_Magi::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "HMi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorH");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- H_Magi::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "HMhp%d\0", ID);
- H_Magi::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- H_Magi::mUnit->attachObject(hpSet);
-
-
- //spell particles
- char spell[10];
- sprintf(spell, "HMsp%d\0", ID);
- H_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
- H_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
- sprintf(spell, "HMsp%dN", ID);
- H_Magi::psNode = H_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
- H_Magi::psNode->attachObject(H_Magi::ps);
- H_Magi::psNode->translate(0,1,0);
- H_Magi::psNode->pitch(Ogre::Degree(-90));
- H_Magi::psNode->lookAt(H_Magi::mDirection,Ogre::Node::TS_WORLD);
- H_Magi::ps->setVisible(false);
- H_Magi::spellDir = Ogre::Vector3::ZERO;
-
- //build decal
- dec = new TerrainDecal(Ogre::String(H_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- H_Magi::cdTimer.reset(); proximityToken = NULL;
- }
-
- H_Magi::H_Magi(){};
-
- O_Brute::O_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- O_Brute::damage = BRUTE_DAMAGE;
- O_Brute::walkSpeed = BRUTE_WALKSPEED;
- O_Brute::health = BRUTE_HEALTH;
- O_Brute::attackSpeed = BRUTE_ATTACKSPEED;
- O_Brute::attackRange = BRUTE_ATTACKRANGE;
- O_Brute::isAttacking = false;
- O_Brute::moving = 0;
- O_Brute::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(O_Brute::name, "OB%d", ID);
-
- O_Brute::mEntity = mSceneMgr->createEntity(O_Brute::name, "goblin_warrior.MESH");
- O_Brute::mEntity->setQueryFlags(ORC_MASK);
- O_Brute::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = O_Brute::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("O_BRUTE/idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_BRUTE/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_BRUTE/Rslash1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = O_Brute::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Rslash1", 0, 6.53);
-
-
- //set animation
- O_Brute::mAnimationState = O_Brute::mEntity->getAnimationState("idle");
- O_Brute::mAnimationState->setLoop(true);
- O_Brute::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- O_Brute::mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(O_Brute::name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(O_Brute::mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "OBi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorO");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- O_Brute::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "OBhp%d\0", ID);
- O_Brute::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- O_Brute::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(O_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- O_Brute::cdTimer.reset(); proximityToken = NULL;
- }
-
- O_Brute::O_Brute(){};
-
- O_Scout::O_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- O_Scout::damage = SCOUT_DAMAGE;
- O_Scout::walkSpeed = SCOUT_WALKSPEED;
- O_Scout::health = SCOUT_HEALTH;
- O_Scout::attackSpeed = SCOUT_ATTACKSPEED;
- O_Scout::attackRange = SCOUT_ATTACKRANGE;
- O_Scout::isAttacking = false;
- O_Scout::moving = 0;
- O_Scout::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(O_Scout::name, "OS%d", ID);
-
- O_Scout::mEntity = mSceneMgr->createEntity(O_Scout::name, "goblin_pygmy.MESH");
- O_Scout::mEntity->setQueryFlags(ORC_MASK);
- O_Scout::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = O_Scout::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("O_Scout/idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Scout/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Scout/Rslash1.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = O_Scout::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Rslash1", 0, 6.53);
-
-
- //set animation
- O_Scout::mAnimationState = O_Scout::mEntity->getAnimationState("idle");
- O_Scout::mAnimationState->setLoop(true);
- O_Scout::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "OSi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorO");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- O_Scout::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "OShp%d\0", ID);
- O_Scout::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- O_Scout::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(O_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- O_Scout::cdTimer.reset(); proximityToken = NULL;
- }
-
- O_Scout::O_Scout(){};
-
- O_Ranged::O_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- O_Ranged::damage = RANGED_DAMAGE;
- O_Ranged::walkSpeed = RANGED_WALKSPEED;
- O_Ranged::health = RANGED_HEALTH;
- O_Ranged::attackSpeed = RANGED_ATTACKSPEED;
- O_Ranged::attackRange = RANGED_ATTACKRANGE;
- O_Ranged::isAttacking = false;
- O_Ranged::moving = 0;
- O_Ranged::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(O_Ranged::name, "OR%d", ID);
-
- O_Ranged::mEntity = mSceneMgr->createEntity(O_Ranged::name, "goblin_archer.MESH");
- O_Ranged::mEntity->setQueryFlags(ORC_MASK);
- O_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = O_Ranged::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("O_Ranged/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Ranged/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Ranged/Bow.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = O_Ranged::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Bow", 0, 6.53);
-
-
- //set animation
- O_Ranged::mAnimationState = O_Ranged::mEntity->getAnimationState("Idle");
- O_Ranged::mAnimationState->setLoop(true);
- O_Ranged::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "ORi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorO");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- O_Ranged::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "ORhp%d\0", ID);
- O_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- O_Ranged::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(O_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- O_Ranged::cdTimer.reset(); proximityToken = NULL;
- }
-
- O_Ranged::O_Ranged(){};
-
- O_Magi::O_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- O_Magi::damage = MAGI_DAMAGE;
- O_Magi::walkSpeed = MAGI_WALKSPEED;
- O_Magi::health = MAGI_HEALTH;
- O_Magi::attackSpeed = MAGI_ATTACKSPEED;
- O_Magi::attackRange = MAGI_ATTACKRANGE;
- O_Magi::isAttacking = false;
- O_Magi::moving = 0;
- O_Magi::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(O_Magi::name, "OM%d", ID);
-
- O_Magi::mEntity = mSceneMgr->createEntity(O_Magi::name, "Goblin_Healer.MESH");
- O_Magi::mEntity->setQueryFlags(ORC_MASK);
- O_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = O_Magi::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("O_Magi/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Magi/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Magi/Wand1.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("O_Magi/Cast_Omni.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = O_Magi::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Wand1", 0, 6.53);
- pass->createAnimationState("Cast_Omni", 0, 6.53);
-
-
- //set animation
- O_Magi::mAnimationState = O_Magi::mEntity->getAnimationState("Idle");
- O_Magi::mAnimationState->setLoop(true);
- O_Magi::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "OMi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorO");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- O_Magi::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "OMhp%d\0", ID);
- O_Magi::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- O_Magi::mUnit->attachObject(hpSet);
-
-
- //spell particles
- char spell[10];
- sprintf(spell, "OMsp%d\0", ID);
- O_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
- O_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
- sprintf(spell, "OMsp%dN", ID);
- O_Magi::psNode = O_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
- O_Magi::psNode->attachObject(O_Magi::ps);
- O_Magi::psNode->translate(0,1,0);
- O_Magi::psNode->pitch(Ogre::Degree(-90));
- O_Magi::psNode->lookAt(O_Magi::mDirection,Ogre::Node::TS_WORLD);
- O_Magi::ps->setVisible(false);
- O_Magi::spellDir = Ogre::Vector3::ZERO;
-
- //build decal
- dec = new TerrainDecal(Ogre::String(O_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- O_Magi::cdTimer.reset(); proximityToken = NULL;
- }
-
- O_Magi::O_Magi(){};
-
- U_Brute::U_Brute(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- U_Brute::damage = BRUTE_DAMAGE;
- U_Brute::walkSpeed = BRUTE_WALKSPEED;
- U_Brute::health = BRUTE_HEALTH;
- U_Brute::attackSpeed = BRUTE_ATTACKSPEED;
- U_Brute::attackRange = BRUTE_ATTACKRANGE;
- U_Brute::isAttacking = false;
- U_Brute::moving = 0;
- U_Brute::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //2,20,Walk1
- //22,36,Walk2
- //38,47,Defense1
- //48,57,Defense2
- //59,75,Die1
- //78,88,Twitch
- //91,103,Die2
- //106,115,Kick
- //117,128,Punch
- //129,136,HeadButt
- //137,169,Idle1
- //170,200,Idle2
-
- //create entity
- sprintf(U_Brute::name, "UB%d", ID);
- U_Brute::mEntity = mSceneMgr->createEntity(U_Brute::name, "zombie.mesh");
- U_Brute::mEntity->setQueryFlags(UNDEAD_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = U_Brute::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Walk.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_BRUTE/Hit.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = U_Brute::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Walk", 0, 4.26);
- pass->createAnimationState("Hit", 0, 6.53);
-
- //set animation
- U_Brute::mAnimationState = U_Brute::mEntity->getAnimationState("Idle");
- U_Brute::mAnimationState->setLoop(true);
- U_Brute::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "UBi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorU");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- U_Brute::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "UBhp%d\0", ID);
- U_Brute::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- U_Brute::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(U_Brute::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- U_Brute::cdTimer.reset(); proximityToken = NULL;
- }
-
- U_Brute::U_Brute(){};
-
-
- U_Scout::U_Scout(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- U_Scout::damage = SCOUT_DAMAGE;
- U_Scout::walkSpeed = SCOUT_WALKSPEED;
- U_Scout::health = SCOUT_HEALTH;
- U_Scout::attackSpeed = SCOUT_ATTACKSPEED;
- U_Scout::attackRange = SCOUT_ATTACKRANGE;
- U_Scout::isAttacking = false;
- U_Scout::moving = 0;
- U_Scout::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(U_Scout::name, "US%d", ID);
- U_Scout::mEntity = mSceneMgr->createEntity(U_Scout::name, "zombiB.mesh");
- U_Scout::mEntity->setQueryFlags(UNDEAD_MASK);
-
- //set animation
- U_Scout::mAnimationState = U_Scout::mEntity->getAnimationState("Idle1");
- U_Scout::mAnimationState->setLoop(true);
- U_Scout::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
-
-
- //minimap indicator 0426-abe
- char i[7];
- sprintf(i, "USi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorU");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- U_Scout::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "UShp%d\0", ID);
- U_Scout::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- U_Scout::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(U_Scout::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- U_Scout::cdTimer.reset(); proximityToken = NULL;
- }
-
- U_Scout::U_Scout(){};
-
- U_Ranged::U_Ranged(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- U_Ranged::damage = RANGED_DAMAGE;
- U_Ranged::walkSpeed = RANGED_WALKSPEED;
- U_Ranged::health = RANGED_HEALTH;
- U_Ranged::attackSpeed = RANGED_ATTACKSPEED;
- U_Ranged::attackRange = RANGED_ATTACKRANGE;
- U_Ranged::isAttacking = false;
- U_Ranged::moving = 0;
- U_Ranged::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(U_Ranged::name, "UR%d", ID);
-
- U_Ranged::mEntity = mSceneMgr->createEntity(U_Ranged::name, "skeleton_unarmed.MESH");
- U_Ranged::mEntity->setQueryFlags(UNDEAD_MASK);
- U_Ranged::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = U_Ranged::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("U_Ranged/Idle_Unarmed.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_Ranged/Run_Unarmed.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_Ranged/Bow2.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = U_Ranged::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle_Unarmed", 0, 6.2);
- pass->createAnimationState("Run_Unarmed", 0, 4.26);
- pass->createAnimationState("Bow2", 0, 6.53);
-
-
- //set animation
- U_Ranged::mAnimationState = U_Ranged::mEntity->getAnimationState("Idle_Unarmed");
- U_Ranged::mAnimationState->setLoop(true);
- U_Ranged::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "URi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorU");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- U_Ranged::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "URhp%d\0", ID);
- U_Ranged::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 20, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- U_Ranged::mUnit->attachObject(hpSet);
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(U_Ranged::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- U_Ranged::cdTimer.reset(); proximityToken = NULL;
- }
-
- U_Ranged::U_Ranged(){};
-
- U_Magi::U_Magi(int ID, Ogre::SceneManager * mSceneMgr, Ogre::Vector3 pos, Ogre::Quaternion rot, Ogre::Vector3 scale){
- curTargetWeight = -1;
- //initialize character settings
- U_Magi::damage = MAGI_DAMAGE;
- U_Magi::walkSpeed = MAGI_WALKSPEED;
- U_Magi::health = MAGI_HEALTH;
- U_Magi::attackSpeed = MAGI_ATTACKSPEED;
- U_Magi::attackRange = MAGI_ATTACKRANGE;
- U_Magi::isAttacking = false;
- U_Magi::moving = 0;
- U_Magi::selected = false;
-
- targetBarracks = NULL;
- targetUnit = NULL;
-
- //create entity
- sprintf(U_Magi::name, "UM%d", ID);
-
- U_Magi::mEntity = mSceneMgr->createEntity(U_Magi::name, "Disciple.MESH");
- U_Magi::mEntity->setQueryFlags(UNDEAD_MASK);
- U_Magi::mEntity->setVisibilityFlags(NONMINIMAP_MASK);
-
- //BONE ANIMATION SETUP
- Ogre::SkeletonInstance* pSK = U_Magi::mEntity->getSkeleton();
- pSK->addLinkedSkeletonAnimationSource("U_Magi/Idle.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_Magi/Run.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_Magi/Rwand1.SKELETON");
- pSK->addLinkedSkeletonAnimationSource("U_Magi/Special_Gen_Cast.SKELETON");
-
- //STORE THE ANIMATIONS
- Ogre::AnimationStateSet* pass = U_Magi::mEntity->getAllAnimationStates();
- pass->removeAllAnimationStates();
- pass->createAnimationState("Idle", 0, 6.2);
- pass->createAnimationState("Run", 0, 4.26);
- pass->createAnimationState("Rwand1", 0, 6.53);
- pass->createAnimationState("Special_Gen_Cast", 0, 6.53);
-
-
- //set animation
- U_Magi::mAnimationState = U_Magi::mEntity->getAnimationState("Idle");
- U_Magi::mAnimationState->setLoop(true);
- U_Magi::mAnimationState->setEnabled(true);
-
- //create this unit's sceneNode
- mUnit = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::String(name), pos);
- Ogre::SceneNode* ent = mUnit->createChildSceneNode();
- ent->attachObject(mEntity);
- ent->setScale(scale);
- ent->setOrientation(rot);
-
- //minimap indicator 0426-abe
-
- char i[7];
- sprintf(i, "UMi%d\0", ID);
- Ogre::BillboardSet* set = mSceneMgr->createBillboardSet(i);
- set->setPoolSize(1);
- set->setMaterialName("Examples/IndicatorO");
- Ogre::Billboard* me = set->createBillboard(Ogre::Vector3(0, 50, 0));
- set->setVisibilityFlags(MINIMAP_MASK);
- me->setDimensions(size_indicator, size_indicator);
- U_Magi::mUnit->attachObject(set);
-
-
- //health bar
- char health[8];
- sprintf(health, "UMhp%d\0", ID);
- U_Magi::hpSet = mSceneMgr->createBillboardSet(health);
- hpSet->setPoolSize(1);
- hpSet->setMaterialName("Examples/HP");
- Ogre::Billboard* hp = hpSet->createBillboard(0, 30, 0);
- hp->setDimensions(HP_SIZE_X,HP_SIZE_Y);
- U_Magi::mUnit->attachObject(hpSet);
-
- //spell particles
- char spell[10];
- sprintf(spell, "UMsp%d\0", ID);
- U_Magi::ps = mSceneMgr->createParticleSystem(spell,"Examples/spell1");
- U_Magi::ps->setVisibilityFlags(NONMINIMAP_MASK);
- sprintf(spell, "UMsp%dN", ID);
- U_Magi::psNode = U_Magi::mEntity->getParentSceneNode()->createChildSceneNode(spell);
- U_Magi::psNode->attachObject(U_Magi::ps);
- U_Magi::psNode->translate(0,1,0);
- U_Magi::psNode->pitch(Ogre::Degree(-90));
- U_Magi::psNode->lookAt(U_Magi::mDirection,Ogre::Node::TS_WORLD);
- U_Magi::ps->setVisible(false);
- U_Magi::spellDir = Ogre::Vector3::ZERO;
-
-
- //build decal
- dec = new TerrainDecal(Ogre::String(U_Magi::name), "Examples/SelectorRingG", Ogre::Vector2(10,10), Ogre::Vector2(0,0),mSceneMgr);
- dec->hide();
-
- //start cooldown timer
- U_Magi::cdTimer.reset(); proximityToken = NULL;
- }
-
- U_Magi::U_Magi(){};
-
-
- //UNIT COMMAND FUNCTIONS
-
- void Unit::initializeMovement(Ogre::Vector3 dest){
- Unit::mDestination = dest;
- Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
- Unit::mDistance = Unit::mDirection.normalise();
- Unit::mDistance = Unit::mDistance*Unit::mDistance;
- //align the orientation for specific models
- Unit::setAnimation_Orientation();
-
- //remove the y-axis rotation to keep models standing straight
- Unit::src.y = 0;
- Unit::mDirection.y = 0;
-
- if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
- {
- Unit::mUnit->yaw(Ogre::Degree(180));
- }
- else
- {
- Ogre::Quaternion quat = Unit::src.getRotationTo(Unit::mDirection);
- Unit::mUnit->rotate(quat);
- } // else
-
- //get animation
- setAnimation_Walk();
-
- //change status so the units actually move.
- Unit::moving = 1;
- }
-
-
- bool Unit::setTarget(Barracks *target, Ogre::Real w){
- if(target->controlRace != Unit::name[0]){
- Unit::isAttacking = true; //set my attack mode to true
- Unit::targetBarracks = target; //and assign the taget name so updateAnimations() can operate
- Unit::curTargetWeight = w;
- }
- else{
- return false;
- }
- return true;
- }
- bool Unit::setTarget(Unit *target, Ogre::Real w){
- if(target != NULL)
- {
- if(target->name[0] != Unit::name[0]){
- Unit::isAttacking = true; //set my attack mode to true
- Unit::targetUnit = target; //and assign the taget name so updateAnimations() can operate
- Unit::curTargetWeight = w;
- return true;
- }
- else{
- return false;
- }
- }
- else
- {
- return false;
- }
-
- }
-
- Unit::~Unit()
- {
- Unit::dec->~TerrainDecal();
- }
-
- void Unit::removeTarget(){
- Unit::isAttacking = false; //set my attack mode to false
- Unit::targetUnit = NULL; //and nullify my target
- Unit::targetBarracks = NULL; //and nullify my target
- Unit::setAnimation_Idle(); //set animation to Idle as well
- }
-
- void Unit::targetBarrDestroyed(){
- //destroy tower
- if(targetBarracks->hasTower)
- {
- //hide tower
- targetBarracks->mTower->setVisible(false);
- targetBarracks->maxHealth = 500;
- targetBarracks->hasTower = false;
- }
-
- targetBarracks->controlRace = Unit::name[0];
- targetBarracks->health = 500;
- targetBarracks->hpSet->getBillboard(0)->setDimensions(BARRACK_HP_SIZE_X,BARRACK_HP_SIZE_Y);
- Ogre::String raceT;
- raceT = targetBarracks->controlRace;
- targetBarracks->mEntity->setMaterialName("barrack"+ raceT +"/kosciol");
- targetBarracks->dec->setMaterial("Examples/SelectorRingG");
- Ogre::String temp = targetBarracks->name;
- targetBarracks->wasReset = true;
- targetBarracks->SFireSet = false;
- targetBarracks->MFireSet = false;
- targetBarracks->LFireSet = false;
- Ogre::String tempie;
- tempie = targetBarracks->controlRace;
- targetBarracks->MinimapSet->setMaterialName("Examples/Indicator"+tempie);
-
- if(Unit::name[1] == 'M'){
- switch(Unit::name[0]){
- case 'O':
- ((O_Magi*)this)->ps->setVisible(false);
- break;
-
- case 'U':
- ((U_Magi*)this)->ps->setVisible(false);
- break;
- case 'H':
- ((H_Magi*)this)->ps->setVisible(false);
- break;
- case 'C':
- ((C_Magi*)this)->ps->setVisible(false);
- break;
- }
- }
- }
-
- void Unit::targetUnitDestroyed(){
-
- targetUnit->health = 0;
- targetUnit->hpSet->getBillboard(0)->setDimensions(0,0);
-
- targetUnit->mUnit->getAttachedObject(1)->setVisible(false);
- targetUnit->mEntity->setVisible(false);
- targetUnit->dec->hide();
-
- targetUnit->mUnit->getParentSceneNode()->removeAndDestroyChild(targetUnit->mUnit->getName());
- targetUnit->mUnit = NULL;
-
- if(Unit::name[1] == 'M'){
- switch(Unit::name[0]){
- case 'O':
- ((O_Magi*)this)->ps->setVisible(false);
- break;
-
- case 'U':
- ((U_Magi*)this)->ps->setVisible(false);
- break;
- case 'H':
- ((H_Magi*)this)->ps->setVisible(false);
- break;
- case 'C':
- ((C_Magi*)this)->ps->setVisible(false);
- break;
- }
- }
-
- }
-
-
- bool Unit::attackBarracks(){
- if(targetBarracks->controlRace == Unit::name[0]){
- Unit::removeTarget();
- return true;
- }
- Ogre::Real distanceBetween = Unit::mUnit->getPosition().distance(targetBarracks->mNode->getPosition());
- if(distanceBetween <= (Unit::attackRange + 25)){ //if I'm within my attack range, attack
- Unit::setAnimation_Attack(); //set animation to Attack as well
-
- //rotate the model to attack
- Unit::mDestination = targetBarracks->mNode->getPosition();
- Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
- Unit::mDistance = Unit::mDirection.normalise();
-
- //align the orientation for specific models
- Unit::setAnimation_Orientation();
-
- Ogre::Quaternion quat;
-
- //remove the y-axis rotation to keep models standing straight
- Unit::src.y = 0;
- Unit::mDirection.y = 0;
-
- if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
- {
- Unit::mUnit->yaw(Ogre::Degree(180));
- }
- else
- {
- quat = Unit::src.getRotationTo(Unit::mDirection);
- Unit::mUnit->rotate(quat);
- } // else
-
- if(Unit::mEntity->getName().substr(1,1) == "M"){
-
- Ogre::Vector3 normie;
- std::stringstream oss;
-
- switch(Unit::mEntity->getName().at(0)){
- case 'O':
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((O_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((O_Magi*)this)->psNode->rotate(quat);
- normie = ((O_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((O_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((O_Magi*)this)->ps->getEmitter(0)->setDirection(((O_Magi*)this)->spellDir);
- ((O_Magi*)this)->ps->setVisible(true);
- break;
-
- case 'U':
- //((U_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((U_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((U_Magi*)this)->psNode->rotate(quat);
- normie = ((U_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((U_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((U_Magi*)this)->ps->getEmitter(0)->setDirection(((U_Magi*)this)->spellDir);
- ((U_Magi*)this)->ps->setVisible(true);
- break;
- case 'H':
- //((H_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((H_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((H_Magi*)this)->psNode->rotate(quat);
- normie = ((H_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((H_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((H_Magi*)this)->ps->getEmitter(0)->setDirection(((H_Magi*)this)->spellDir);
- ((H_Magi*)this)->ps->setVisible(true);
- break;
- case 'C':
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((C_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((C_Magi*)this)->psNode->rotate(quat);
- normie = ((C_Magi*)this)->spellDir;
- normie.x *= 10;
- normie.y = 0;
- normie.z *= 10;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((C_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((C_Magi*)this)->ps->getEmitter(0)->setDirection(((C_Magi*)this)->spellDir);
- ((C_Magi*)this)->ps->setVisible(true);
- break;
- }
- }
-
- Unit::moving = false;
- if(Unit::cdTimer.getMilliseconds() > Unit::attackSpeed){ //if my cooldown's done..
- targetBarracks->health -= Unit::damage;
- targetBarracks->hpSet->getBillboard(0)->setDimensions(BARRACK_HP_SIZE_X*(targetBarracks->health/targetBarracks->maxHealth),BARRACK_HP_SIZE_Y);
- if(targetBarracks->health <= 0){
- Unit::targetBarrDestroyed();
- return false;
- }
- Unit::cdTimer.reset();
- }
- }
- else{ //otherwise, walk towards my opponent
- if(Unit::mEntity->getName().substr(1,1) == "M"){
- switch(Unit::mEntity->getName().at(0)){
- case 'O':
- ((O_Magi*)this)->ps->setVisible(false);
- break;
-
- case 'U':
-
- break;
- case 'H':
-
- break;
- case 'C':
- ((C_Magi*)this)->ps->setVisible(false);
- break;
- }
- }
- Unit::initializeMovement(targetBarracks->mNode->getPosition());
- }
- return true;
- }
-
- bool Unit::attackUnit(){
- if((targetUnit->name[0] == Unit::name[0]) || (targetUnit->mUnit == NULL)){
- Unit::removeTarget();
- return true;
- }
- Ogre::Real distanceBetween = Unit::mUnit->getPosition().distance(targetUnit->mUnit->getPosition());
- if(distanceBetween <= Unit::attackRange){ //if I'm within my attack range, attack
- Unit::setAnimation_Attack(); //set animation to Attack as well
-
- //rotate the model to attack
- Unit::mDestination = targetUnit->mUnit->getPosition();
- Unit::mDirection = Unit::mDestination - Unit::mUnit->getPosition();
- Unit::mDistance = Unit::mDirection.normalise();
-
- //align the orientation for specific models
- Unit::setAnimation_Orientation();
-
- Ogre::Quaternion quat;
-
- //remove the y-axis rotation to keep models standing straight
- Unit::src.y = 0;
- Unit::mDirection.y = 0;
-
- if ((1.0f + Unit::src.dotProduct(Unit::mDirection)) < 0.0001f)
- {
- Unit::mUnit->yaw(Ogre::Degree(180));
- }
- else
- {
- quat = Unit::src.getRotationTo(Unit::mDirection);
- Unit::mUnit->rotate(quat);
- } // else
-
- if(Unit::mEntity->getName().substr(1,1) == "M"){
-
- Ogre::Vector3 normie;
- std::stringstream oss;
-
- switch(Unit::mEntity->getName().at(0)){
- case 'O':
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((O_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((O_Magi*)this)->psNode->rotate(quat);
- normie = ((O_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((O_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((O_Magi*)this)->ps->getEmitter(0)->setDirection(((O_Magi*)this)->spellDir);
- ((O_Magi*)this)->ps->setVisible(true);
- break;
-
- case 'U':
- //((U_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((U_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((U_Magi*)this)->psNode->rotate(quat);
- normie = ((U_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((U_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((U_Magi*)this)->ps->getEmitter(0)->setDirection(((U_Magi*)this)->spellDir);
- ((U_Magi*)this)->ps->setVisible(true);
- break;
- case 'H':
- //((H_Magi*)(*ii).second)->psNode->lookAt((*ii).second->mDirection,Ogre::Node::TS_WORLD);
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((H_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((H_Magi*)this)->psNode->rotate(quat);
- normie = ((H_Magi*)this)->spellDir;
- normie.x *= 55;
- normie.y = 0;
- normie.z *= 55;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((H_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((H_Magi*)this)->ps->getEmitter(0)->setDirection(((H_Magi*)this)->spellDir);
- ((H_Magi*)this)->ps->setVisible(true);
- break;
- case 'C':
- if(Unit::mDirection != Ogre::Vector3::ZERO){
- ((C_Magi*)this)->spellDir = Unit::mDirection;
- }
- ((C_Magi*)this)->psNode->rotate(quat);
- normie = ((C_Magi*)this)->spellDir;
- normie.x *= 10;
- normie.y = 0;
- normie.z *= 10;
- oss << normie.x << " " << normie.y << " " << normie.z;
- ((C_Magi*)this)->ps->getAffector(0)->setParameter("force_vector", oss.str());
- ((C_Magi*)this)->ps->getEmitter(0)->setDirection(((C_Magi*)this)->spellDir);
- ((C_Magi*)this)->ps->setVisible(true);
- break;
- }
- }
-
- Unit::moving = false;
- if(Unit::cdTimer.getMilliseconds() > Unit::attackSpeed){ //if my cooldown's done..
- targetUnit->health -= Unit::damage;
- int maxHealth = 0;
- switch(targetUnit->name[1]){
- case 'B':
- maxHealth = BRUTE_HEALTH;
- break;
- case 'S':
- maxHealth = SCOUT_HEALTH;
- break;
- case 'R':
- maxHealth = RANGED_HEALTH;
- break;
- case 'M':
- maxHealth = MAGI_HEALTH;
- break;
- }
- Ogre::Real tempF;
- tempF = (Ogre::Real) targetUnit->health / maxHealth;
- tempF *= HP_SIZE_X;
- targetUnit->hpSet->getBillboard(0)->setDimensions(tempF,HP_SIZE_Y);
- if(targetUnit->health <= 0){
- //Unit::targetUnitDestroyed();
- return false;
- }
- Unit::cdTimer.reset();
- }
- }
- else{ //otherwise, walk towards my opponent
- if(Unit::mEntity->getName().substr(1,1) == "M"){
- switch(Unit::mEntity->getName().at(0)){
- case 'O':
- ((O_Magi*)this)->ps->setVisible(false);
- break;
-
- case 'U':
- //Undead not implemented
- break;
- case 'H':
- //Human not implemented
- break;
- case 'C':
- ((C_Magi*)this)->ps->setVisible(false);
- break;
- }
- }
- Unit::initializeMovement(targetUnit->mUnit->getPosition());
- }
- return true;
- }
-
-
- void Unit::setAnimation_Walk(){
- Ogre::String compName = Unit::mUnit->getName().substr(0,2);
- if(compName == "US"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Walk1");
- }
- else if(compName == "OB" || compName == "OS" || compName == "HR" || compName == "OR" || compName == "OM" || compName == "UM" || compName == "CS" || compName == "CM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Run");
- }
- else if(compName == "CR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("armed");
- }
- else if(compName == "HS"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("run");
- }
- else if(compName == "HM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle");
- }
- else if(compName == "UR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Run_Unarmed");
- }
- else{
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Walk");
- }
- Unit::mAnimationState->setLoop(true);
- Unit::mAnimationState->setEnabled(true);
- }
-
- void Unit::setAnimation_Idle(){
- // Set Idle animation
- Ogre::String compName = Unit::mUnit->getName().substr(0,2);
- if(compName == "CB" || compName == "UB" || compName == "HR" || compName == "OR" || compName == "OM" || compName == "UM" || compName == "CS" || compName == "CM" || compName == "HM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle");
- }
- else if(compName == "HB"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle3");
- }
- else if(compName == "US"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle1");
- }
- else if(compName == "OB" || compName == "OS" || compName == "HS"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("idle");
- }
- else if(compName == "UR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Idle_Unarmed");
- }
- else if(compName == "CR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("armed");
- }
-
- Unit::mAnimationState->setLoop(true);
- Unit::mAnimationState->setEnabled(true);
- };
-
- void Unit::setAnimation_Attack(){
- // Set Attack animation
- Ogre::String compName = Unit::mUnit->getName().substr(0,2);
- if(compName == "CB"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Shoot");
- }
- else if(compName == "HB"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Attack1");
- }
- else if(compName == "US"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("HeadButt"); //Punch Kick
- }
- else if(compName == "OM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Cast_Omni");
- }
- else if(compName == "UM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Special_Gen_Cast");
- }
- else if(compName == "OB" || compName == "OS"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Rslash1");
- }
- else if(compName == "OR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow");
- }
- else if(compName == "UR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow2");
- }
- else if(compName == "CS"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Attack1");
- }
- else if(compName == "CR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("attack");
- }
- else if(compName == "CM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Special_Spray_Left");
- }
- else if(compName == "HS"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("rslash1");
- }
- else if(compName == "HM"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Fidget1");
- }
- else if(compName == "HR"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Bow1");
- }
- else if(compName == "UB"){
- Unit::mAnimationState = Unit::mEntity->getAnimationState("Hit");
- }
-
- Unit::mAnimationState->setLoop(true);
- Unit::mAnimationState->setEnabled(true);
- };
-
- void Unit::setAnimation_Orientation(){
- //align the orientation for specific models
- Ogre::String compName = Unit::mUnit->getName().substr(0,2);
- if(compName == "CB"){
- Unit::src = Unit::mUnit->getOrientation() * Ogre::Vector3::UNIT_X;
- }
- else if(compName == "HB"){
- Unit::src = Unit::mUnit->getOrientation() * -(Ogre::Vector3::UNIT_Z);
- }
- else if(compName == "UB" || compName == "US"){
- Unit::src = Unit::mUnit->getOrientation() * (Ogre::Vector3::UNIT_Z);
- }
- 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"){
- Unit::src = Unit::mUnit->getOrientation() * (Ogre::Vector3::UNIT_Z);
- }
- };
-
-
- Ogre::Real Unit::getWeight(Unit* target){
- Ogre::Real weight = -1.0;
- if(target && this->name!=""){
- if(target->name[1] != 'b'){
- weight = (target->mUnit->getPosition()-mUnit->getPosition()).squaredLength();
- weight = 50000.0/weight - target->health+280;
- if(target->targetUnit !=NULL){
- if(target->targetUnit->name[0] == name[0]){
- weight+=150;
- }
- }
- else if(target->targetBarracks !=NULL){
- if(target->targetBarracks->name[0] == name[0]){
- weight+=200;
- }
- }
- }
- }
-
-
- return weight;
- };
-
-
- Ogre::Real Unit::getWeight(Barracks* target){
- Ogre::Real weight = -1.0;
-
- weight = (target->mNode->getPosition()- mUnit->getPosition()).squaredLength()/700 + target->health/2 + 150;
-
- return weight;
- };
* This source code was highlighted with Source Code Highlighter.
|
|