Compare commits
No commits in common. "945baf09945b14eb688af48a5dc236e658ee2d5f" and "8a3717eac3f1b25071c4a10d534687c44ac01594" have entirely different histories.
945baf0994
...
8a3717eac3
|
@ -5,7 +5,6 @@
|
|||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
void HitscanMuzzle::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("shoot"), &self_type::shoot);
|
||||
BIND_PROPERTY(Variant::FLOAT, spread);
|
||||
BIND_PROPERTY(Variant::INT, damage);
|
||||
BIND_PROPERTY(Variant::INT, ray_count);
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
#include "revolver.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "wave_survival/macros.h"
|
||||
#include "wave_survival/player_camera.h"
|
||||
#include "wave_survival/player_input.h"
|
||||
|
||||
void Revolver::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("start_recoil"), &self_type::start_recoil);
|
||||
BIND_PROPERTY(Variant::FLOAT, single_action_spread);
|
||||
BIND_PROPERTY(Variant::FLOAT, double_action_spread);
|
||||
}
|
||||
|
||||
void Revolver::play_equip_anim() {
|
||||
|
@ -18,26 +14,15 @@ void Revolver::play_equip_anim() {
|
|||
|
||||
void Revolver::shoot() {
|
||||
if (!is_animating()) {
|
||||
this->muzzle->shoot();
|
||||
if (this->alt_active) {
|
||||
get_anim()->queue("fire_single");
|
||||
this->alt_active = false;
|
||||
this->muzzle->set_spread(this->single_action_spread);
|
||||
this->muzzle->shoot();
|
||||
start_recoil();
|
||||
get_anim()->queue("idle_single");
|
||||
} else {
|
||||
this->muzzle->set_spread(this->double_action_spread);
|
||||
get_anim()->queue("fire_double");
|
||||
}
|
||||
get_anim()->queue("idle_double");
|
||||
}
|
||||
}
|
||||
|
||||
void Revolver::cock_hammer() {
|
||||
if (!this->alt_active && !is_animating()) {
|
||||
this->alt_active = true;
|
||||
get_anim()->queue("to_single");
|
||||
get_anim()->queue("idle_single");
|
||||
}
|
||||
}
|
||||
|
||||
void Revolver::on_primary_fire(bool pressed) {
|
||||
|
@ -47,9 +32,7 @@ void Revolver::on_primary_fire(bool pressed) {
|
|||
}
|
||||
|
||||
void Revolver::on_alt_mode(bool pressed) {
|
||||
if (!this->alt_active && pressed) {
|
||||
cock_hammer();
|
||||
}
|
||||
this->alt_requested = pressed;
|
||||
}
|
||||
|
||||
void Revolver::ready() {
|
||||
|
@ -60,12 +43,11 @@ void Revolver::ready() {
|
|||
}
|
||||
|
||||
void Revolver::process(double delta) {
|
||||
//String const current{ get_anim()->get_current_animation() };
|
||||
//double animation_time{ get_anim()->get_current_animation_position() };
|
||||
if (this->recoil_timer > 0.0) {
|
||||
this->recoil_timer -= delta;
|
||||
double t{ 1.0 - CLAMP(this->recoil_timer / this->recoil_time, 0.0, 1.0) };
|
||||
get_camera()->recoil(Math::lerp((double)this->recoil_force, 0.0, t) * delta);
|
||||
String const current{ get_anim()->get_current_animation() };
|
||||
double animation_time{ get_anim()->get_current_animation_position() };
|
||||
if (current == "fire_single" || current == "fire_double") {
|
||||
double t{ animation_time / this->recoil_time };
|
||||
get_camera()->recoil(Math::lerp((double)this->recoil_force, 0.0, CLAMP(t, 0.0, 1.0)) * delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,27 +71,3 @@ void Revolver::_notification(int what) {
|
|||
void Revolver::notify_selected() {
|
||||
play_equip_anim();
|
||||
}
|
||||
|
||||
bool Revolver::allows_running() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Revolver::start_recoil() {
|
||||
this->recoil_timer = this->recoil_time;
|
||||
}
|
||||
|
||||
void Revolver::set_single_action_spread(float value) {
|
||||
this->single_action_spread = value;
|
||||
}
|
||||
|
||||
float Revolver::get_single_action_spread() const {
|
||||
return this->single_action_spread;
|
||||
}
|
||||
|
||||
void Revolver::set_double_action_spread(float value) {
|
||||
this->double_action_spread = value;
|
||||
}
|
||||
|
||||
float Revolver::get_double_action_spread() const {
|
||||
return this->double_action_spread;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ class Revolver : public WeaponBase {
|
|||
static void _bind_methods();
|
||||
void play_equip_anim();
|
||||
void shoot();
|
||||
void cock_hammer();
|
||||
void on_primary_fire(bool pressed);
|
||||
void on_alt_mode(bool pressed);
|
||||
void ready();
|
||||
|
@ -18,24 +17,14 @@ class Revolver : public WeaponBase {
|
|||
protected:
|
||||
void _notification(int what);
|
||||
virtual void notify_selected() override;
|
||||
virtual bool allows_running() const override;
|
||||
|
||||
public:
|
||||
void start_recoil();
|
||||
void set_single_action_spread(float value);
|
||||
float get_single_action_spread() const;
|
||||
void set_double_action_spread(float value);
|
||||
float get_double_action_spread() const;
|
||||
|
||||
private:
|
||||
float single_action_spread{ 0.01f };
|
||||
float double_action_spread{ 0.03f };
|
||||
bool alt_requested{ false };
|
||||
bool alt_active{ false };
|
||||
HitscanMuzzle *muzzle{ nullptr };
|
||||
|
||||
float recoil_force{ 2.f };
|
||||
double recoil_time{ 0.06 };
|
||||
double recoil_timer{ 0.0 };
|
||||
float recoil_time{ 0.06f };
|
||||
};
|
||||
|
||||
#endif // !WEAPONS_REVOLVER_H
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -1,9 +1,8 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://cc2adfb3sfrep"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://cc2adfb3sfrep"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://snjgu4yp5swd" path="res://objects/player.tscn" id="1_mhgjp"]
|
||||
[ext_resource type="PackedScene" uid="uid://dllho5nkq2smw" path="res://maps/industrial_area_map.tscn" id="2_41t38"]
|
||||
[ext_resource type="PackedScene" uid="uid://bt054d3ic71rf" path="res://menus/pause_menu.tscn" id="2_ien74"]
|
||||
[ext_resource type="Texture2D" uid="uid://bwfkmwx6bd5u4" path="res://icon.svg" id="4_41t38"]
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ien74"]
|
||||
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
|
||||
|
@ -49,19 +48,3 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20.454895, 0.006988764, -8.1
|
|||
[node name="Map" parent="SubViewportContainer/SubViewport" instance=ExtResource("2_41t38")]
|
||||
|
||||
[node name="PauseMenu" parent="." instance=ExtResource("2_ien74")]
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
focus_behavior_recursive = 1
|
||||
mouse_filter = 2
|
||||
mouse_behavior_recursive = 1
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
|
||||
custom_minimum_size = Vector2(10, 10)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("4_41t38")
|
||||
expand_mode = 4
|
||||
|
|
|
@ -4,49 +4,23 @@
|
|||
|
||||
[node name="Revolver" type="Revolver" node_paths=PackedStringArray("anim")]
|
||||
anim = NodePath("revolver/AnimationPlayer")
|
||||
single_action_spread = 0.003
|
||||
double_action_spread = 0.02
|
||||
|
||||
[node name="revolver" parent="." instance=ExtResource("1_5ynga")]
|
||||
|
||||
[node name="Skeleton3D" parent="revolver/Character" index="0"]
|
||||
bones/1/position = Vector3(0.077683, 0.15356629, 0.22951864)
|
||||
bones/1/rotation = Quaternion(0.5851843, 0.4764963, 0.47324383, -0.45447868)
|
||||
bones/2/rotation = Quaternion(-0.13058601, 0.036996037, 0.61635554, 0.7756832)
|
||||
bones/3/rotation = Quaternion(0.041782245, 0.11465855, 0.27514994, 0.9536247)
|
||||
bones/4/rotation = Quaternion(0.14384021, 0.35639, -0.26087254, 0.8855742)
|
||||
bones/5/rotation = Quaternion(-0.22070737, 0.14418077, 0.13519569, 0.95510334)
|
||||
bones/6/rotation = Quaternion(-0.10018806, 0.0017374308, -0.01725145, 0.99481744)
|
||||
bones/7/rotation = Quaternion(-0.5670921, 0.0002677271, -0.0003900336, 0.82365435)
|
||||
bones/8/rotation = Quaternion(-0.679744, 0.1527604, 0.07346371, 0.7135934)
|
||||
bones/9/rotation = Quaternion(-0.52413255, -0.0052551352, 0.008540803, 0.85157764)
|
||||
bones/10/rotation = Quaternion(-0.45302963, 0.0016381256, -0.0032266823, 0.89148813)
|
||||
bones/11/rotation = Quaternion(-0.6447599, 0.17695157, 0.030249309, 0.74300593)
|
||||
bones/12/rotation = Quaternion(-0.61815894, -0.0058423677, 0.008146217, 0.78598917)
|
||||
bones/13/rotation = Quaternion(-0.2895717, 0.0008908666, -0.0035062192, 0.95714957)
|
||||
bones/14/rotation = Quaternion(-0.41372666, 0.18337816, -0.05571315, 0.88999933)
|
||||
bones/15/rotation = Quaternion(-0.56248397, 0.0085162, 0.018579094, 0.82655555)
|
||||
bones/16/rotation = Quaternion(-0.5171131, -0.0032988985, -0.01302587, 0.8558117)
|
||||
bones/17/position = Vector3(-0.035217408, 0.031610176, 0.010926676)
|
||||
bones/17/rotation = Quaternion(-0.4766158, 0.022983566, 0.16551939, 0.8630831)
|
||||
bones/18/rotation = Quaternion(0.30545127, -0.076055326, -0.15467335, 0.9364782)
|
||||
bones/19/rotation = Quaternion(0.008012294, 0.013962945, -0.36334667, 0.9315149)
|
||||
bones/20/rotation = Quaternion(0.5851843, -0.4764963, -0.47324383, -0.45447868)
|
||||
bones/39/position = Vector3(0.075784564, -0.25414097, -0.44517958)
|
||||
bones/39/rotation = Quaternion(-0.14452313, 2.8000815e-17, 2.8000815e-17, 0.9895014)
|
||||
bones/40/position = Vector3(0.018712092, 0.02616787, 0.005937299)
|
||||
bones/43/rotation = Quaternion(0.0037203024, 1.1920845e-07, 4.4349532e-10, 0.9999931)
|
||||
bones/44/rotation = Quaternion(0.9970487, -9.1520045e-09, 1.1885747e-07, -0.07677229)
|
||||
|
||||
[node name="Body" parent="revolver/Character/Skeleton3D" index="0"]
|
||||
layers = 2
|
||||
|
||||
[node name="Cube" parent="revolver/Character/Skeleton3D" index="1"]
|
||||
layers = 2
|
||||
|
||||
[node name="HitscanMuzzle" type="HitscanMuzzle" parent="."]
|
||||
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="revolver/Character/Skeleton3D" index="2"]
|
||||
transform = Transform3D(1, -6.350722e-17, 4.732016e-17, 4.732016e-17, 0.95822614, 0.28601173, -6.350722e-17, -0.28601173, 0.95822614, -1.1196792e-16, -0.03667751, 0.009908612)
|
||||
bone_name = "root"
|
||||
bone_idx = 39
|
||||
|
||||
[node name="HitscanMuzzle" type="HitscanMuzzle" parent="revolver/Character/Skeleton3D/BoneAttachment3D"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, -4.3711385e-08, 0.9999999, 0, -0.9999999, -4.3711385e-08, 0, 0, 0)
|
||||
transform = Transform3D(1, 6.3507215e-17, 4.732015e-17, -6.350722e-17, 0.28601167, 0.958226, 4.7320157e-17, -0.958226, 0.28601167, -9.044954e-18, 0.04726258, 0.25400588)
|
||||
target_position = Vector3(0, 200, 0)
|
||||
collision_mask = 6
|
||||
collide_with_areas = true
|
||||
|
|
|
@ -13,16 +13,21 @@ layers = 2
|
|||
[node name="mesh" parent="rifle/Character/Skeleton3D" index="1"]
|
||||
layers = 2
|
||||
|
||||
[node name="AnimationPlayer" parent="rifle" index="2"]
|
||||
playback_default_blend_time = 0.1
|
||||
[node name="BoneAttachment3D" type="BoneAttachment3D" parent="rifle/Character/Skeleton3D" index="2"]
|
||||
transform = Transform3D(1, -2.0932122e-15, 2.3524223e-18, 2.3525281e-18, 0.0022477505, 0.99999744, -2.0932126e-15, -0.9999974, 0.0022477508, 0.07988295, -0.13953947, -0.33976445)
|
||||
bone_name = "root"
|
||||
bone_idx = 39
|
||||
|
||||
[node name="HitscanMuzzle" type="HitscanMuzzle" parent="."]
|
||||
[node name="HitscanMuzzle" type="HitscanMuzzle" parent="rifle/Character/Skeleton3D/BoneAttachment3D"]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, -2.0932111e-15, -2.7987948e-18, 2.3525281e-18, -0.00021316158, 0.99999976, -2.0932126e-15, -0.9999997, -0.00021316111, 0, 0, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 0.9999968, 0.0024609112, 0, -0.0024609112, 0.9999968, 1.1099746e-16, 0.053034816, 0.03427495)
|
||||
target_position = Vector3(0, 200, 0)
|
||||
collision_mask = 6
|
||||
collide_with_areas = true
|
||||
spread = 0.003
|
||||
damage = 3
|
||||
|
||||
[node name="AnimationPlayer" parent="rifle" index="2"]
|
||||
playback_default_blend_time = 0.1
|
||||
|
||||
[editable path="rifle"]
|
||||
|
|
Loading…
Reference in a new issue