new param <anim-hp-bound value="true"/> for BeBuilt skill to have the animation progress bound to the HP. / fixed a nullpointer exception related to particles

This commit is contained in:
Titus Tscharntke 2011-07-02 16:07:04 +00:00
parent 8e1836220d
commit a1ab98d4b9
3 changed files with 25 additions and 3 deletions

View File

@ -1250,8 +1250,12 @@ bool Unit::update() {
float speedDenominator = (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()));
progress += (speed * diagonalFactor * heightFactor) / speedDenominator;
animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator;
if(currSkill->getClass() == scBeBuilt && static_cast<const BeBuiltSkillType*>(currSkill)->getAnimHpBound()==true ){
animProgress=this->getHpRatio();
}
else{
animProgress += (currSkill->getAnimSpeed() * heightFactor) / speedDenominator;
}
//update target
updateTarget();
@ -2230,7 +2234,7 @@ void Unit::stopDamageParticles(bool force) {
}
}
}
if(force == true || pst->getMinmaxEnabled() == false) {
if(force == true || ( pst !=NULL && pst->getMinmaxEnabled() == false )) {
damageParticleSystemsInUse.erase(foundParticleIndexType);
ps->fade();
damageParticleSystems.pop_back();

View File

@ -625,6 +625,20 @@ BeBuiltSkillType::BeBuiltSkillType(){
skillClass= scBeBuilt;
}
void BeBuiltSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt,
const FactionType *ft, std::map<string,vector<pair<string, string> > > &loadedFileList,
string parentLoader) {
SkillType::load(sn, dir, tt, ft, loadedFileList, parentLoader);
if(sn->hasChild("anim-hp-bound")){
animHpBound= sn->getChild("anim-hp-bound")->getAttribute("value")->getBoolValue();
}
else {
animHpBound=false;
}
}
string BeBuiltSkillType::toString() const{
return "Be built";
}

View File

@ -303,7 +303,11 @@ public:
// ===============================
class BeBuiltSkillType: public SkillType{
private:
bool animHpBound;
public:
bool getAnimHpBound() const {return animHpBound;}
BeBuiltSkillType();
virtual string toString() const;
};