diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index e4a2a9c2..19e96717 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1364,7 +1364,7 @@ void Unit::setTarget(const Unit *unit){ //ser field and vector targetField= unit->getCurrField(); - targetVec= unit->getCurrVector(); + targetVec= unit->getCurrVectorAsTarget(); targetRef= unit; } @@ -1615,6 +1615,36 @@ Vec3f Unit::getCurrVector() const{ return result; } +Vec3f Unit::getCurrVectorAsTarget() const{ + if(type == NULL) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str()); + throw megaglest_runtime_error(szBuf); + } + + Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getTargetHeight() / 2.f, 0.f); + result.x = truncateDecimal(result.x,6); + result.y = truncateDecimal(result.y,6); + result.z = truncateDecimal(result.z,6); + + return result; +} + +Vec3f Unit::getCurrBurnVector() const{ + if(type == NULL) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"In [%s::%s Line: %d] ERROR: type == NULL, Unit = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,this->toString().c_str()); + throw megaglest_runtime_error(szBuf); + } + + Vec3f result = getCurrVectorFlat() + Vec3f(0.f, type->getBurnHeight() / 2.f, 0.f); + result.x = truncateDecimal(result.x,6); + result.y = truncateDecimal(result.y,6); + result.z = truncateDecimal(result.z,6); + + return result; +} + Vec3f Unit::getCurrVectorFlat() const{ return getVectorFlat(lastPos, pos); } @@ -3699,7 +3729,7 @@ void Unit::updateTarget(){ #else targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); #endif - targetVec= target->getCurrVector(); + targetVec= target->getCurrVectorAsTarget(); } } @@ -4257,7 +4287,7 @@ void Unit::startDamageParticles() { fps->setParticleOwner(this); const Game *game = Renderer::getInstance().getGame(); fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex())); - fps->setPos(getCurrVector()); + fps->setPos(getCurrBurnVector()); fps->setRadius(type->getSize()/3.f); fps->setTexture(CoreData::getInstance().getFireTexture()); fps->setParticleSize(type->getSize()/3.f); @@ -4271,7 +4301,7 @@ void Unit::startDamageParticles() { ups->setParticleOwner(this); ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f)); ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f)); - ups->setPos(getCurrVector()); + ups->setPos(getCurrBurnVector()); ups->setRotation(getRotation()); ups->setUnitModel(getCurrentModelPtr()); ups->setBlendMode(ups->strToBlendMode("black")); @@ -4297,11 +4327,6 @@ void Unit::startDamageParticles() { checkCustomizedParticleTriggers(false); } -//void Unit::setTargetVec(const Vec3f &targetVec) { -// this->targetVec= targetVec; -// logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__); -//} - void Unit::setMeetingPos(const Vec2i &meetingPos) { this->meetingPos= meetingPos; map->clampPos(this->meetingPos); diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 9c0381d9..c8742a70 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -638,6 +638,8 @@ public: const Model *getCurrentModel(); Model *getCurrentModelPtr(); Vec3f getCurrVector() const; + Vec3f getCurrVectorAsTarget() const; + Vec3f getCurrBurnVector() const; Vec3f getCurrVectorFlat() const; Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const; diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index fdaa3a36..f0f905d5 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -235,6 +235,22 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); addItemToVault(&(this->height),this->height); + //targetHeight + if(parametersNode->hasChild("target-height")){ + targetHeight= parametersNode->getChild("target-height")->getAttribute("value")->getIntValue(); + addItemToVault(&(this->targetHeight),this->targetHeight); + } else { + targetHeight=height; + } + //burnHeight + if(parametersNode->hasChild("target-height")){ + burnHeight= parametersNode->getChild("burn-height")->getAttribute("value")->getIntValue(); + addItemToVault(&(this->burnHeight),this->burnHeight); + } else { + burnHeight=height; + } + + //maxHp //checkItemInVault(&(this->maxHp),this->maxHp); maxHp = parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue(); diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 77fbdaf4..43c36d81 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -187,6 +187,8 @@ private: int size; //size in cells int renderSize; //size to render in cells int height; + int burnHeight; + int targetHeight; float rotatedBuildPos; bool rotationAllowed; @@ -275,8 +277,10 @@ public: inline int getSight() const {return sight;} inline int getSize() const {return size;} inline int getRenderSize() const {return renderSize;} - int getHeight() const {return height;} - int getStoredResourceCount() const {return (int)storedResources.size();} + int getHeight() const {return height;} + int getBurnHeight() const {return burnHeight;} + int getTargetHeight() const {return targetHeight;} + int getStoredResourceCount() const {return (int)storedResources.size();} inline const Resource *getStoredResource(int i) const {return &storedResources[i];} int getLootableResourceCount() const {return lootableResources.size();} inline const LootableResource getLootableResource(int i) const {return lootableResources.at(i);}