diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index 00b6bba1..01143bdf 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -834,6 +834,7 @@ AttackSkillType::AttackSkillType() { splashRadius= 0; spawnUnit=""; spawnUnitcount=0; + spawnUnitAtTarget=false; splashParticleSystemType= NULL; for(int i = 0; i < fieldCount; ++i) { @@ -886,11 +887,16 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode, if (sn->hasChild("unit")) { spawnUnit = sn->getChild("unit")->getAttribute("value")->getValue(); - spawnUnitcount - = sn->getChild("unit")->getAttribute("amount")->getIntValue(); + spawnUnitcount = sn->getChild("unit")->getAttribute("amount")->getIntValue(); + if(sn->getChild("unit")->hasAttribute("spawnAtTarget")) { + spawnUnitAtTarget = sn->getChild("unit")->getAttribute("spawnAtTarget")->getBoolValue(); + } else { + spawnUnitAtTarget = false; + } } else { spawnUnit = ""; spawnUnitcount = 0; + spawnUnitAtTarget = false; } //attack fields const XmlNode *attackFieldsNode= sn->getChild("attack-fields"); @@ -1053,6 +1059,8 @@ void AttackSkillType::saveGame(XmlNode *rootNode) { attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements); // int spawnUnitcount; attackSkillTypeNode->addAttribute("spawnUnitcount",intToStr(spawnUnitcount), mapTagReplacements); +// bool spawnUnitAtTarget; + attackSkillTypeNode->addAttribute("spawnUnitAtTarget",intToStr(spawnUnitAtTarget), mapTagReplacements); // bool projectile; attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements); // ParticleSystemTypeProjectile* projectileParticleSystemType; diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h index 290c1903..c0b4f3b8 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -292,6 +292,7 @@ private: string spawnUnit; int spawnUnitcount; + bool spawnUnitAtTarget; bool projectile; //ParticleSystemTypeProjectile* projectileParticleSystemType; SoundContainer projSounds; @@ -318,6 +319,7 @@ public: inline float getAttackStartTime() const {return attackStartTime;} inline string getSpawnUnit() const {return spawnUnit;} inline int getSpawnUnitCount() const {return spawnUnitcount;} + inline bool getSpawnUnitAtTarget() const {return spawnUnitAtTarget;} //get proj inline bool getProjectile() const {return projectile;} diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index c9dc9e7f..67ba4266 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -298,7 +298,13 @@ bool UnitUpdater::updateUnit(Unit *unit) { Vec2i(0), spawnUnitType, unit->getFaction(), world->getMap(), CardinalDir::NORTH); //SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] about to place unit for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,spawned->toString().c_str()); - if(!world->placeUnit(unit->getCenteredPos(), 10, spawned)) { + bool placedSpawnUnit=false; + if(act->getAttackSkillType()->getSpawnUnitAtTarget()) { + placedSpawnUnit=world->placeUnit(unit->getTargetPos(), 10, spawned); + } else { + placedSpawnUnit=world->placeUnit(unit->getCenteredPos(), 10, spawned); + } + if(!placedSpawnUnit) { //SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] COULD NOT PLACE UNIT for unitID [%d]\n",__FILE__,__FUNCTION__,__LINE__,spawned->getId()); // This will also cleanup newPath @@ -309,10 +315,10 @@ bool UnitUpdater::updateUnit(Unit *unit) { spawned->create(); spawned->born(ct); world->getStats()->produce(unit->getFactionIndex(),spawned->getType()->getCountUnitProductionInStats()); - const CommandType *ct= spawned->computeCommandType(command->getPos(),command->getUnit()); + const CommandType *ct= spawned->computeCommandType(unit->getTargetPos(),map->getCell(unit->getTargetPos())->getUnit(unit->getTargetField())); if(ct != NULL){ if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - spawned->giveCommand(new Command(ct, unit->getMeetingPos())); + spawned->giveCommand(new Command(ct, unit->getTargetPos())); } scriptManager->onUnitCreated(spawned);