void CEnemyMeleeAttack::onTick(unsigned int msecs) { //BaseSubsystems::Log::Debug(std::to_string(_count)+" - "+_entity->getName() + " Acumulando tiempo de ataque: "+std::to_string(_timeAcum)+" / "+std::to_string(_timeBetweenAttacks)); _timeAcum += msecs; if(canDoDamage()) { Vector3 dir = _target->getPosition() - _entity->getPosition(); if( dir.squaredLength() <= _maxDist2) { Vector3 offsetPos = _entity->getPosition(); offsetPos.y += _upOffset; CEntity* ent; Vector3 collisionPoint; if (_target->getTag() == "player") { ent = Physics::CServer::getSingletonPtr()->raycastSimple(offsetPos, dir, _maxDist ,Physics::CollisionGroup::ePlayer,collisionPoint); if (ent) { ApplyDamage(ent); //Instanciamos la chispa en el punto de colision CEntityFactory::getSingletonPtr()->createEntityByType("ChispaDanhoPlayer", collisionPoint, _entity->getMap()); damageEnemy(collisionPoint); } } else if (_target->getTag() == "enemy") { std::vector<Vector3> pointsCollision; Physics::FilterMask mask = Physics::FilterMask(Physics::FilterMask::eEnemyTMask |Physics::FilterMask::eEnemyVMask); std::vector<Logic::CEntity*> vecLEnt = Physics::CServer::getSingletonPtr()->raycastMultiple(offsetPos, dir, _maxDist, 64, mask,pointsCollision); for (int i = 0; i < vecLEnt.size(); ++i) { if (vecLEnt.at(i)->getEntityID() == _targetID) { ApplyDamage(vecLEnt.at(i)); //Generamos particula de choque CEntityFactory::getSingletonPtr()->createEntityByType("ChispaDanhoEnemy", pointsCollision.at(i), _entity->getMap()); break; } } } } } }//tick
void test_KillAnEnemy() { freeAllEnemies(); createTestEnemy(); damageEnemy(INT_BASIC_HEALTH, getNumberOfEnemies(), INT_TYPE); }