Add modified weapon models

This commit is contained in:
2022-12-07 08:41:10 +01:00
parent 307eec1f4e
commit d2ed1afdc7
23 changed files with 428 additions and 283 deletions

View File

@@ -0,0 +1,5 @@
extends Node
class_name Hitable
func Hit():
print("Got hit")

View File

@@ -35,6 +35,8 @@ func init():
var tween = create_tween()
MODEL.position = DRAW_POS
MODEL.rotation = DRAW_ROT
can_shoot = true
tween.tween_callback(InitialPos).set_delay(DRAW_TIME)
@@ -42,8 +44,8 @@ func init():
func InitialPos():
var tween = create_tween()
tween.set_trans(Tween.TRANS_CIRC)
tween.set_ease(Tween.EASE_IN_OUT)
tween.set_trans(Tween.TRANS_QUAD)
tween.set_parallel(true)
tween.tween_property(MODEL, "position", Vector3.ZERO, RECOIL_COOLDOWN / 2)
tween.tween_property(MODEL, "rotation", Vector3.ZERO, RECOIL_COOLDOWN / 2)
@@ -84,7 +86,7 @@ func Reload():
tween.set_trans(Tween.TRANS_CIRC)
tween.set_ease(Tween.EASE_IN)
tween.set_parallel(true)
tween.tween_property(MODEL, "position", ANGULAR_MOMENTUM, RELOAD_TIME)
tween.tween_property(MODEL, "position", RELOAD_MOMENTUM, RELOAD_TIME)
tween.tween_property(MODEL, "rotation", RELOAD_ANGULAR_MOMENTUM, RELOAD_TIME)
tween.tween_callback(init).set_delay(RELOAD_TIME)
clip = MAX_CLIP

View File

@@ -2,6 +2,7 @@ extends Node3D
const CONFIG_PATH = "user://weapons.scoom"
const REVOLVER = 0
const UZI = 1
const REST = 0
@@ -32,6 +33,26 @@ var file_data = {
"RELOAD_MOMENTUM": Vector3(-5, -9, 7),
"RELOAD_ANGULAR_MOMENTUM": Vector3(deg_to_rad(600), deg_to_rad(-800), deg_to_rad(-1000)),
"RELOAD_TIME": 0.35,
"FIREMODE": 0,
"HITSCAN": true
},
UZI:
{
"HAND_POS": Vector3(0.4,-0.45,-1),
"HAND_ROT": Vector3(0,PI,0),
"MODEL": "Uzi",
"MAX_CLIP": 30,
"DAMAGE": 25,
"MOMENTUM": Vector2(0.05, -0.15),
"ANGULAR_MOMENTUM": Vector3(-4, 1, 2),
"RECOIL_COOLDOWN": 0.35,
"RPM": 600,
"DRAW_POS": Vector3(0,-0.5,-0.3),
"DRAW_ROT": Vector3(1.3, 0, 0),
"RELOAD_MOMENTUM": Vector3(-7, -9, 7),
"RELOAD_ANGULAR_MOMENTUM": Vector3(deg_to_rad(600), deg_to_rad(-800), deg_to_rad(-1000)),
"RELOAD_TIME": 0.35,
"FIREMODE": 1,
"HITSCAN": true
}
}
@@ -72,6 +93,7 @@ func _ready():
root.DRAW_POS = file_data[i].DRAW_POS
root.DRAW_ROT = file_data[i].DRAW_ROT
root.HITSCAN = file_data[i].HITSCAN
root.FIREMODE = file_data[i].FIREMODE
if(not root.HITSCAN):
print("Projectile stats")
@@ -97,7 +119,7 @@ func _unhandled_input(_event):
func ChangeWeapon(i):
weapons[current_weapon].hide()
current_weapon = (i)
current_weapon = i
weapons[current_weapon].init()
raycast.target_position.z = -weapons[current_weapon].RAY_LEN
@@ -119,7 +141,7 @@ func _process(delta):
mouse_mov = Vector3.ZERO
else:
weapons[current_weapon].MODEL.rotation = weapons[current_weapon].MODEL.rotation.lerp(Vector3.ZERO, sway_lerp * delta)
#BOB
if player_root.velocity.length() > 0:
time += delta
@@ -132,7 +154,11 @@ func _process(delta):
func HitScan():
if(raycast.is_colliding()):
var target = raycast.get_collider()
print("Hit target ", target.name)
print_debug("Hit target ", target.name, " with ", weapons[current_weapon].MODEL.name, " ",current_weapon, ". Dealt damage ", weapons[current_weapon].DAMAGE)
if(raycast.get_collision_mask_value(10)):
if(target is Hitable):
target.Hit()
func Projectile():
pass