multishot with more than one attack particle system

This commit is contained in:
titiger 2014-07-10 23:34:39 +02:00
parent a5e8e6df02
commit dff810a5b1
3 changed files with 23 additions and 20 deletions

View File

@ -806,7 +806,6 @@ AttackSkillType::AttackSkillType() {
splashRadius= 0; splashRadius= 0;
spawnUnit=""; spawnUnit="";
spawnUnitcount=0; spawnUnitcount=0;
projectileParticleSystemType= NULL;
splashParticleSystemType= NULL; splashParticleSystemType= NULL;
for(int i = 0; i < fieldCount; ++i) { for(int i = 0; i < fieldCount; ++i) {
@ -821,8 +820,8 @@ AttackSkillType::AttackSkillType() {
} }
AttackSkillType::~AttackSkillType() { AttackSkillType::~AttackSkillType() {
delete projectileParticleSystemType;
projectileParticleSystemType = NULL; deleteValues(projectileParticleSystemTypes.begin(), projectileParticleSystemTypes.end());
delete splashParticleSystemType; delete splashParticleSystemType;
splashParticleSystemType = NULL; splashParticleSystemType = NULL;
@ -887,16 +886,18 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
if(projectile){ if(projectile){
//proj particle //proj particle
const XmlNode *particleNode= projectileNode->getChild("particle"); if(projectileNode->hasChild("particle")){
bool particleEnabled= particleNode->getAttribute("value")->getBoolValue(); const XmlNode *particleNode= projectileNode->getChild("particle");
if(particleEnabled){ bool particleEnabled= particleNode->getAttribute("value")->getBoolValue();
string path= particleNode->getAttribute("path")->getRestrictedValue(); if(particleEnabled){
projectileParticleSystemType= new ParticleSystemTypeProjectile(); string path= particleNode->getAttribute("path")->getRestrictedValue();
projectileParticleSystemType->load(particleNode, dir, currentPath + path, ParticleSystemTypeProjectile* projectileParticleSystemType= new ParticleSystemTypeProjectile();
&Renderer::getInstance(), loadedFileList, parentLoader, projectileParticleSystemType->load(particleNode, dir, currentPath + path,
tt->getPath()); &Renderer::getInstance(), loadedFileList, parentLoader,
loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleNode->getAttribute("path")->getRestrictedValue())); tt->getPath());
projectileParticleSystemTypes.push_back(projectileParticleSystemType); loadedFileList[currentPath + path].push_back(make_pair(parentLoader,particleNode->getAttribute("path")->getRestrictedValue()));
projectileParticleSystemTypes.push_back(projectileParticleSystemType);
}
} }
//extra projectiles //extra projectiles
@ -907,7 +908,7 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
for(int i = 0; i < (int)extraParticlesNode->getChildCount(); ++i) { for(int i = 0; i < (int)extraParticlesNode->getChildCount(); ++i) {
const XmlNode *extraParticleFileNode= extraParticlesNode->getChild("particle-file", i); const XmlNode *extraParticleFileNode= extraParticlesNode->getChild("particle-file", i);
string path= extraParticleFileNode->getAttribute("path")->getRestrictedValue(); string path= extraParticleFileNode->getAttribute("path")->getRestrictedValue();
projectileParticleSystemType= new ParticleSystemTypeProjectile(); ParticleSystemTypeProjectile* projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(extraParticleFileNode, dir, currentPath + path, projectileParticleSystemType->load(extraParticleFileNode, dir, currentPath + path,
&Renderer::getInstance(), loadedFileList, parentLoader, &Renderer::getInstance(), loadedFileList, parentLoader,
tt->getPath()); tt->getPath());
@ -1007,9 +1008,10 @@ void AttackSkillType::saveGame(XmlNode *rootNode) {
// bool projectile; // bool projectile;
attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements); attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements);
// ParticleSystemTypeProjectile* projectileParticleSystemType; // ParticleSystemTypeProjectile* projectileParticleSystemType;
if(projectileParticleSystemType != NULL) { // save a skill_type ????
projectileParticleSystemType->saveGame(attackSkillTypeNode); // if(projectileParticleSystemType != NULL) {
} // projectileParticleSystemType->saveGame(attackSkillTypeNode);
// }
// SoundContainer projSounds; // SoundContainer projSounds;
// //
// bool splash; // bool splash;

View File

@ -271,7 +271,7 @@ private:
string spawnUnit; string spawnUnit;
int spawnUnitcount; int spawnUnitcount;
bool projectile; bool projectile;
ParticleSystemTypeProjectile* projectileParticleSystemType; //ParticleSystemTypeProjectile* projectileParticleSystemType;
SoundContainer projSounds; SoundContainer projSounds;
bool splash; bool splash;
@ -299,7 +299,7 @@ public:
//get proj //get proj
inline bool getProjectile() const {return projectile;} inline bool getProjectile() const {return projectile;}
inline ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;} //inline ParticleSystemTypeProjectile * getProjParticleType() const {return projectileParticleSystemType;}
inline StaticSound *getProjSound() const {return projSounds.getRandSound();} inline StaticSound *getProjSound() const {return projSounds.getRandSound();}
//get splash //get splash

View File

@ -2601,7 +2601,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
if(ast == NULL) { if(ast == NULL) {
throw megaglest_runtime_error("Start attack particle ast == NULL!"); throw megaglest_runtime_error("Start attack particle ast == NULL!");
} }
ParticleSystemTypeProjectile *pstProj= ast->getProjParticleType(); ParticleSystemTypeProjectile *pstProj= NULL;
ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType(); ParticleSystemTypeSplash *pstSplash= ast->getSplashParticleType();
Vec3f startPos= unit->getCurrVector(); Vec3f startPos= unit->getCurrVector();
@ -2626,6 +2626,7 @@ void UnitUpdater::startAttackParticleSystem(Unit *unit){
} }
renderer.manageParticleSystem(psProj, rsGame); renderer.manageParticleSystem(psProj, rsGame);
unit->addAttackParticleSystem(psProj); unit->addAttackParticleSystem(psProj);
pstProj=(*pit);
} }
// if no projectile, still deal damage.. // if no projectile, still deal damage..