damage from the weapon depends on the place where you will hit the enemy

master
Vectozavr 2021-11-07 15:02:16 +07:00
parent 1a96510801
commit fd1573a77d
2 changed files with 15 additions and 3 deletions

View File

@ -150,7 +150,8 @@ void ShooterClient::processCustomPacket(sf::Packet &packet) {
camera->rotateLeft(-camera->angleLeftUpLookAt().x());
camera->transform(Matrix4x4::Rotation(-_player->angle()));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<ATranslateToPoint>(camera, Vec3D(-20, 30, -100)));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<ATranslateToPoint>(camera, Vec3D(0, 30, -100)));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AWait>(0));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<ARotateRelativePoint>(camera, Vec3D(0), Vec3D{0, Consts::PI, 0}, 5, Animation::LoopOut::None, Animation::InterpolationType::Linear));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AWait>(0));
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AFunction>([this, camera](){

View File

@ -99,11 +99,22 @@ Weapon::addTrace(std::function<IntersectionInformation(const Vec3D &, const Vec3
auto rayCast = rayCastFunction(from, from + directionTo * ShooterConsts::FIRE_DISTANCE + randV);
if (rayCast.objectName.str().find("Enemy") != std::string::npos) {
damagedPlayers[rayCast.objectName] += _damage / (1.0 + rayCast.distanceToObject);
// If you hit the head the damage will be doubled
if (rayCast.objectName.str().find("_head") != std::string::npos) {
damagedPlayers[rayCast.objectName] += _damage / (1.0 + rayCast.distanceToObject);
}
// If you hit the foot the damage will be divided by 2
if (rayCast.objectName.str().find("_foot_") != std::string::npos) {
damagedPlayers[rayCast.objectName] -= 0.5 * _damage / (1.0 + rayCast.distanceToObject);
}
}
// add trace line
Vec3D lineFrom = position() + model() * Vec3D(triangles().back()[0]);
Vec3D lineTo = rayCast.intersected ? rayCast.pointOfIntersection : position() + directionTo * ShooterConsts::FIRE_DISTANCE + randV;
Vec3D lineTo = rayCast.intersected ? rayCast.pointOfIntersection : position() +
directionTo * ShooterConsts::FIRE_DISTANCE +
randV;
_addTraceCallBack(lineFrom, lineTo);
return damagedPlayers;