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 //ser field and vector
targetField= unit->getCurrField(); targetField= unit->getCurrField();
targetVec= unit->getCurrVector(); targetVec= unit->getCurrVectorAsTarget();
targetRef= unit; targetRef= unit;
} }
@ -1615,6 +1615,36 @@ Vec3f Unit::getCurrVector() const{
return result; 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{ Vec3f Unit::getCurrVectorFlat() const{
return getVectorFlat(lastPos, pos); return getVectorFlat(lastPos, pos);
} }
@ -3699,7 +3729,7 @@ void Unit::updateTarget(){
#else #else
targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); targetRotation= radToDeg(atan2(relPosf.x, relPosf.y));
#endif #endif
targetVec= target->getCurrVector(); targetVec= target->getCurrVectorAsTarget();
} }
} }
@ -4257,7 +4287,7 @@ void Unit::startDamageParticles() {
fps->setParticleOwner(this); fps->setParticleOwner(this);
const Game *game = Renderer::getInstance().getGame(); const Game *game = Renderer::getInstance().getGame();
fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex())); fps->setSpeed(2.5f / game->getWorld()->getUpdateFps(this->getFactionIndex()));
fps->setPos(getCurrVector()); fps->setPos(getCurrBurnVector());
fps->setRadius(type->getSize()/3.f); fps->setRadius(type->getSize()/3.f);
fps->setTexture(CoreData::getInstance().getFireTexture()); fps->setTexture(CoreData::getInstance().getFireTexture());
fps->setParticleSize(type->getSize()/3.f); fps->setParticleSize(type->getSize()/3.f);
@ -4271,7 +4301,7 @@ void Unit::startDamageParticles() {
ups->setParticleOwner(this); ups->setParticleOwner(this);
ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f)); ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f));
ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f)); ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f));
ups->setPos(getCurrVector()); ups->setPos(getCurrBurnVector());
ups->setRotation(getRotation()); ups->setRotation(getRotation());
ups->setUnitModel(getCurrentModelPtr()); ups->setUnitModel(getCurrentModelPtr());
ups->setBlendMode(ups->strToBlendMode("black")); ups->setBlendMode(ups->strToBlendMode("black"));
@ -4297,11 +4327,6 @@ void Unit::startDamageParticles() {
checkCustomizedParticleTriggers(false); checkCustomizedParticleTriggers(false);
} }
//void Unit::setTargetVec(const Vec3f &targetVec) {
// this->targetVec= targetVec;
// logSynchData(extractFileFromDirectoryPath(__FILE__).c_str(),__LINE__);
//}
void Unit::setMeetingPos(const Vec2i &meetingPos) { void Unit::setMeetingPos(const Vec2i &meetingPos) {
this->meetingPos= meetingPos; this->meetingPos= meetingPos;
map->clampPos(this->meetingPos); map->clampPos(this->meetingPos);

View File

@ -638,6 +638,8 @@ public:
const Model *getCurrentModel(); const Model *getCurrentModel();
Model *getCurrentModelPtr(); Model *getCurrentModelPtr();
Vec3f getCurrVector() const; Vec3f getCurrVector() const;
Vec3f getCurrVectorAsTarget() const;
Vec3f getCurrBurnVector() const;
Vec3f getCurrVectorFlat() const; Vec3f getCurrVectorFlat() const;
Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) 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(); height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
addItemToVault(&(this->height),this->height); 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 //maxHp
//checkItemInVault(&(this->maxHp),this->maxHp); //checkItemInVault(&(this->maxHp),this->maxHp);
maxHp = parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue(); maxHp = parametersNode->getChild("max-hp")->getAttribute("value")->getIntValue();

View File

@ -187,6 +187,8 @@ private:
int size; //size in cells int size; //size in cells
int renderSize; //size to render in cells int renderSize; //size to render in cells
int height; int height;
int burnHeight;
int targetHeight;
float rotatedBuildPos; float rotatedBuildPos;
bool rotationAllowed; bool rotationAllowed;
@ -275,8 +277,10 @@ public:
inline int getSight() const {return sight;} inline int getSight() const {return sight;}
inline int getSize() const {return size;} inline int getSize() const {return size;}
inline int getRenderSize() const {return renderSize;} inline int getRenderSize() const {return renderSize;}
int getHeight() const {return height;} int getHeight() const {return height;}
int getStoredResourceCount() const {return (int)storedResources.size();} 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];} inline const Resource *getStoredResource(int i) const {return &storedResources[i];}
int getLootableResourceCount() const {return lootableResources.size();} int getLootableResourceCount() const {return lootableResources.size();}
inline const LootableResource getLootableResource(int i) const {return lootableResources.at(i);} inline const LootableResource getLootableResource(int i) const {return lootableResources.at(i);}