special height for fire and hitposition can be set in a units

This commit is contained in:
titiger 2014-11-25 22:36:19 +01:00
parent 50b27db1d6
commit 024338429a
4 changed files with 58 additions and 11 deletions

View File

@ -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<float>(result.x,6);
result.y = truncateDecimal<float>(result.y,6);
result.z = truncateDecimal<float>(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<float>(result.x,6);
result.y = truncateDecimal<float>(result.y,6);
result.z = truncateDecimal<float>(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);

View File

@ -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;

View File

@ -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();

View File

@ -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);}