damage from the weapon depends on the place where you will hit the enemy
parent
1a96510801
commit
fd1573a77d
|
@ -150,7 +150,8 @@ void ShooterClient::processCustomPacket(sf::Packet &packet) {
|
||||||
camera->rotateLeft(-camera->angleLeftUpLookAt().x());
|
camera->rotateLeft(-camera->angleLeftUpLookAt().x());
|
||||||
camera->transform(Matrix4x4::Rotation(-_player->angle()));
|
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<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<AWait>(0));
|
||||||
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AFunction>([this, camera](){
|
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AFunction>([this, camera](){
|
||||||
|
|
|
@ -99,11 +99,22 @@ Weapon::addTrace(std::function<IntersectionInformation(const Vec3D &, const Vec3
|
||||||
auto rayCast = rayCastFunction(from, from + directionTo * ShooterConsts::FIRE_DISTANCE + randV);
|
auto rayCast = rayCastFunction(from, from + directionTo * ShooterConsts::FIRE_DISTANCE + randV);
|
||||||
if (rayCast.objectName.str().find("Enemy") != std::string::npos) {
|
if (rayCast.objectName.str().find("Enemy") != std::string::npos) {
|
||||||
damagedPlayers[rayCast.objectName] += _damage / (1.0 + rayCast.distanceToObject);
|
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
|
// add trace line
|
||||||
Vec3D lineFrom = position() + model() * Vec3D(triangles().back()[0]);
|
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);
|
_addTraceCallBack(lineFrom, lineTo);
|
||||||
|
|
||||||
return damagedPlayers;
|
return damagedPlayers;
|
||||||
|
|
Loading…
Reference in New Issue