Added a bool spawnAtTarget to spawn attack in which you can define whether the unit spawns at the target or at the attacker.
In Addition i changed the command which is given to the spawned unit to an attack command on the target cell. ( I think this makes way more sense than giving a move command to the meeting point) ( This also works if the spawned does not have a attack command. It will move to the enemy then)
This commit is contained in:
parent
6fc59dc5f2
commit
6086a33baf
|
@ -834,6 +834,7 @@ AttackSkillType::AttackSkillType() {
|
||||||
splashRadius= 0;
|
splashRadius= 0;
|
||||||
spawnUnit="";
|
spawnUnit="";
|
||||||
spawnUnitcount=0;
|
spawnUnitcount=0;
|
||||||
|
spawnUnitAtTarget=false;
|
||||||
splashParticleSystemType= NULL;
|
splashParticleSystemType= NULL;
|
||||||
|
|
||||||
for(int i = 0; i < fieldCount; ++i) {
|
for(int i = 0; i < fieldCount; ++i) {
|
||||||
|
@ -886,11 +887,16 @@ void AttackSkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
|
||||||
|
|
||||||
if (sn->hasChild("unit")) {
|
if (sn->hasChild("unit")) {
|
||||||
spawnUnit = sn->getChild("unit")->getAttribute("value")->getValue();
|
spawnUnit = sn->getChild("unit")->getAttribute("value")->getValue();
|
||||||
spawnUnitcount
|
spawnUnitcount = sn->getChild("unit")->getAttribute("amount")->getIntValue();
|
||||||
= sn->getChild("unit")->getAttribute("amount")->getIntValue();
|
if(sn->getChild("unit")->hasAttribute("spawnAtTarget")) {
|
||||||
|
spawnUnitAtTarget = sn->getChild("unit")->getAttribute("spawnAtTarget")->getBoolValue();
|
||||||
|
} else {
|
||||||
|
spawnUnitAtTarget = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
spawnUnit = "";
|
spawnUnit = "";
|
||||||
spawnUnitcount = 0;
|
spawnUnitcount = 0;
|
||||||
|
spawnUnitAtTarget = false;
|
||||||
}
|
}
|
||||||
//attack fields
|
//attack fields
|
||||||
const XmlNode *attackFieldsNode= sn->getChild("attack-fields");
|
const XmlNode *attackFieldsNode= sn->getChild("attack-fields");
|
||||||
|
@ -1053,6 +1059,8 @@ void AttackSkillType::saveGame(XmlNode *rootNode) {
|
||||||
attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements);
|
attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements);
|
||||||
// int spawnUnitcount;
|
// int spawnUnitcount;
|
||||||
attackSkillTypeNode->addAttribute("spawnUnitcount",intToStr(spawnUnitcount), mapTagReplacements);
|
attackSkillTypeNode->addAttribute("spawnUnitcount",intToStr(spawnUnitcount), mapTagReplacements);
|
||||||
|
// bool spawnUnitAtTarget;
|
||||||
|
attackSkillTypeNode->addAttribute("spawnUnitAtTarget",intToStr(spawnUnitAtTarget), mapTagReplacements);
|
||||||
// bool projectile;
|
// bool projectile;
|
||||||
attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements);
|
attackSkillTypeNode->addAttribute("projectile",intToStr(projectile), mapTagReplacements);
|
||||||
// ParticleSystemTypeProjectile* projectileParticleSystemType;
|
// ParticleSystemTypeProjectile* projectileParticleSystemType;
|
||||||
|
|
|
@ -292,6 +292,7 @@ private:
|
||||||
|
|
||||||
string spawnUnit;
|
string spawnUnit;
|
||||||
int spawnUnitcount;
|
int spawnUnitcount;
|
||||||
|
bool spawnUnitAtTarget;
|
||||||
bool projectile;
|
bool projectile;
|
||||||
//ParticleSystemTypeProjectile* projectileParticleSystemType;
|
//ParticleSystemTypeProjectile* projectileParticleSystemType;
|
||||||
SoundContainer projSounds;
|
SoundContainer projSounds;
|
||||||
|
@ -318,6 +319,7 @@ public:
|
||||||
inline float getAttackStartTime() const {return attackStartTime;}
|
inline float getAttackStartTime() const {return attackStartTime;}
|
||||||
inline string getSpawnUnit() const {return spawnUnit;}
|
inline string getSpawnUnit() const {return spawnUnit;}
|
||||||
inline int getSpawnUnitCount() const {return spawnUnitcount;}
|
inline int getSpawnUnitCount() const {return spawnUnitcount;}
|
||||||
|
inline bool getSpawnUnitAtTarget() const {return spawnUnitAtTarget;}
|
||||||
|
|
||||||
//get proj
|
//get proj
|
||||||
inline bool getProjectile() const {return projectile;}
|
inline bool getProjectile() const {return projectile;}
|
||||||
|
|
|
@ -298,7 +298,13 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
Vec2i(0), spawnUnitType, unit->getFaction(),
|
Vec2i(0), spawnUnitType, unit->getFaction(),
|
||||||
world->getMap(), CardinalDir::NORTH);
|
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());
|
//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());
|
//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
|
// This will also cleanup newPath
|
||||||
|
@ -309,10 +315,10 @@ bool UnitUpdater::updateUnit(Unit *unit) {
|
||||||
spawned->create();
|
spawned->create();
|
||||||
spawned->born(ct);
|
spawned->born(ct);
|
||||||
world->getStats()->produce(unit->getFactionIndex(),spawned->getType()->getCountUnitProductionInStats());
|
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(ct != NULL){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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);
|
scriptManager->onUnitCreated(spawned);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue