new try with changed fighting behaviour of ultra and mega;

fix for "*" in chat
This commit is contained in:
Titus Tscharntke 2012-06-04 21:53:20 +00:00
parent 771c6d5bd6
commit ca39f8c6b1
4 changed files with 35 additions and 33 deletions

View File

@ -435,11 +435,12 @@ void ChatManager::updateNetwork() {
playerName = this->manualPlayerNameOverride; playerName = this->manualPlayerNameOverride;
} }
if(StartsWith(msg.chatText,"*") && msg.chatText.find(playerName) != string::npos){ if(StartsWith(msg.chatText,"*")){
CoreData &coreData= CoreData::getInstance(); if(msg.chatText.find(playerName) != string::npos){
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.playFx(coreData.getHighlightSound()); soundRenderer.playFx(coreData.getHighlightSound());
}
console->addLine(msg.chatText.substr(1,msg.chatText.size()), true, msg.chatPlayerIndex,Vec3f(1.f, 1.f, 1.f),teamMode); console->addLine(msg.chatText.substr(1,msg.chatText.size()), true, msg.chatPlayerIndex,Vec3f(1.f, 1.f, 1.f),teamMode);
} }
else { else {

View File

@ -602,6 +602,7 @@ public:
int update2(); int update2();
bool update(); bool update();
void tick(); void tick();
RandomGen* getRandom() { return &random; }
bool applyAttackBoost(const AttackBoost *boost, const Unit *source); bool applyAttackBoost(const AttackBoost *boost, const Unit *source);
void deapplyAttackBoost(const AttackBoost *boost, const Unit *source); void deapplyAttackBoost(const AttackBoost *boost, const Unit *source);

View File

@ -2191,17 +2191,17 @@ bool UnitUpdater::searchForResource(Unit *unit, const HarvestCommandType *hct) {
return false; return false;
} }
bool UnitUpdater::attackerOnSight(const Unit *unit, Unit **rangedPtr){ bool UnitUpdater::attackerOnSight(Unit *unit, Unit **rangedPtr){
int range= unit->getType()->getSight(); int range= unit->getType()->getSight();
return unitOnRange(unit, range, rangedPtr, NULL); return unitOnRange(unit, range, rangedPtr, NULL);
} }
bool UnitUpdater::attackableOnSight(const Unit *unit, Unit **rangedPtr, const AttackSkillType *ast){ bool UnitUpdater::attackableOnSight(Unit *unit, Unit **rangedPtr, const AttackSkillType *ast){
int range= unit->getType()->getSight(); int range= unit->getType()->getSight();
return unitOnRange(unit, range, rangedPtr, ast); return unitOnRange(unit, range, rangedPtr, ast);
} }
bool UnitUpdater::attackableOnRange(const Unit *unit, Unit **rangedPtr, const AttackSkillType *ast){ bool UnitUpdater::attackableOnRange(Unit *unit, Unit **rangedPtr, const AttackSkillType *ast){
int range= ast->getTotalAttackRange(unit->getTotalUpgrade()); int range= ast->getTotalAttackRange(unit->getTotalUpgrade());
return unitOnRange(unit, range, rangedPtr, ast); return unitOnRange(unit, range, rangedPtr, ast);
} }
@ -2295,7 +2295,7 @@ void UnitUpdater::findEnemiesForCell(const Vec2i pos, int size, int sightRange,
} }
//if the unit has any enemy on range //if the unit has any enemy on range
bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr,
const AttackSkillType *ast) { const AttackSkillType *ast) {
vector<Unit*> enemies; vector<Unit*> enemies;
bool result=false; bool result=false;
@ -2348,11 +2348,11 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
float distToUnit= -1; float distToUnit= -1;
Unit* enemySeen= NULL; Unit* enemySeen= NULL;
//TT float distToStandingUnit= -1; float distToStandingUnit= -1;
// Unit* attackingEnemySeen= NULL; Unit* attackingEnemySeen= NULL;
// ControlType controlType= unit->getFaction()->getControlType(); ControlType controlType= unit->getFaction()->getControlType();
// bool isUltra= controlType == ctCpuUltra || controlType == ctNetworkCpuUltra; bool isUltra= controlType == ctCpuUltra || controlType == ctNetworkCpuUltra;
// bool isMega= controlType == ctCpuMega || controlType == ctNetworkCpuMega; bool isMega= controlType == ctCpuMega || controlType == ctNetworkCpuMega;
//printf("unit %d has control:%d\n",unit->getId(),controlType); //printf("unit %d has control:%d\n",unit->getId(),controlType);
for(int i = 0; i< enemies.size(); ++i) { for(int i = 0; i< enemies.size(); ++i) {
@ -2376,25 +2376,25 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,
result = true; result = true;
} }
//TT if(isUltra || isMega) { if(isUltra || isMega) {
// if(distToStandingUnit < 0 || currentDist< distToStandingUnit) { if(distToStandingUnit < 0 || currentDist< distToStandingUnit) {
// if(enemies[i]->getCurrSkill()!=NULL && enemies[i]->getCurrSkill()->getClass()==scAttack) { if(enemies[i]->getCurrSkill()!=NULL && enemies[i]->getCurrSkill()->getClass()==scAttack) {
// distToStandingUnit = currentDist; distToStandingUnit = currentDist;
// attackingEnemySeen=enemies[i]; attackingEnemySeen=enemies[i];
// } }
// } }
// } }
} }
} }
} }
//TT if(isUltra || isMega) { if(isUltra || isMega) {
// if( attackingEnemySeen!=NULL && random.randRange(0,2)!=2 ) { if( attackingEnemySeen!=NULL && unit->getRandom()->randRange(0,2)!=2 ) {
// *rangedPtr = attackingEnemySeen; *rangedPtr = attackingEnemySeen;
// enemySeen = attackingEnemySeen; enemySeen = attackingEnemySeen;
// //printf("Da hat er wen gefunden:%s\n",enemySeen->getType()->getName(false).c_str()); //printf("Da hat er wen gefunden:%s\n",enemySeen->getType()->getName(false).c_str());
// } }
// } }
if(result == true) { if(result == true) {
//const Unit* teamUnit = NULL; //const Unit* teamUnit = NULL;

View File

@ -145,10 +145,10 @@ private:
//misc //misc
bool searchForResource(Unit *unit, const HarvestCommandType *hct); bool searchForResource(Unit *unit, const HarvestCommandType *hct);
bool attackerOnSight(const Unit *unit, Unit **enemyPtr); bool attackerOnSight(Unit *unit, Unit **enemyPtr);
bool attackableOnSight(const Unit *unit, Unit **enemyPtr, const AttackSkillType *ast); bool attackableOnSight(Unit *unit, Unit **enemyPtr, const AttackSkillType *ast);
bool attackableOnRange(const Unit *unit, Unit **enemyPtr, const AttackSkillType *ast); bool attackableOnRange(Unit *unit, Unit **enemyPtr, const AttackSkillType *ast);
bool unitOnRange(const Unit *unit, int range, Unit **enemyPtr, const AttackSkillType *ast); bool unitOnRange(Unit *unit, int range, Unit **enemyPtr, const AttackSkillType *ast);
void enemiesAtDistance(const Unit *unit, const Unit *priorityUnit, int distance, vector<Unit*> &enemies); void enemiesAtDistance(const Unit *unit, const Unit *priorityUnit, int distance, vector<Unit*> &enemies);
Unit * findPeerUnitBuilder(Unit *unit); Unit * findPeerUnitBuilder(Unit *unit);