Initial commit
This commit is contained in:
24
actors/Enemies/Spider/SpiderFollowPlayer.gd
Normal file
24
actors/Enemies/Spider/SpiderFollowPlayer.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends EnemyState
|
||||
|
||||
const maxFollowDistance: float = 12.5
|
||||
|
||||
func Enter():
|
||||
if enemy_ref.spiderLight:
|
||||
enemy_ref.spiderLight.visible = true
|
||||
if enemy_ref.hitBoxTeeth:
|
||||
enemy_ref.hitBoxTeeth.active = true
|
||||
|
||||
func Exit():
|
||||
enemy_ref.can_move = true
|
||||
if enemy_ref.spiderLight:
|
||||
enemy_ref.spiderLight.visible = false
|
||||
if enemy_ref.hitBoxTeeth:
|
||||
enemy_ref.hitBoxTeeth.active = false
|
||||
|
||||
func Update(_delta: float):
|
||||
if enemy_ref.closestPlayer:
|
||||
if enemy_ref.distanceClosestPlayer > maxFollowDistance:
|
||||
Transitioned.emit(self, "Wander")
|
||||
|
||||
enemy_ref.can_move = enemy_ref.distanceClosestPlayer > 2
|
||||
enemy_ref.pathfind(enemy_ref.closestPlayerGridPosition)
|
||||
1
actors/Enemies/Spider/SpiderFollowPlayer.gd.uid
Normal file
1
actors/Enemies/Spider/SpiderFollowPlayer.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dc8gd7klgokxu
|
||||
18
actors/Enemies/Spider/SpiderWander.gd
Normal file
18
actors/Enemies/Spider/SpiderWander.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
extends EnemyState
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var arrived: bool = true
|
||||
var wanderGoal: Vector2
|
||||
const wanderSpeed := 2.3
|
||||
const wanderRange: float = 20
|
||||
const detectionRange: float = 8
|
||||
|
||||
func Update(_delta: float) -> void:
|
||||
if enemy_ref.distanceClosestPlayer < detectionRange:
|
||||
Transitioned.emit(self,"FollowPlayer")
|
||||
if arrived:
|
||||
wanderGoal = Vector2(rng.randf_range(-wanderRange,wanderRange),rng.randf_range(-wanderRange,wanderRange))
|
||||
arrived = false
|
||||
enemy_ref.pathfind(wanderGoal,wanderSpeed)
|
||||
if enemy_ref.pointPath.size() <= 2:
|
||||
arrived = true
|
||||
1
actors/Enemies/Spider/SpiderWander.gd.uid
Normal file
1
actors/Enemies/Spider/SpiderWander.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dyhvo1kt3kb5e
|
||||
36
actors/Enemies/Spider/ik_target.gd
Normal file
36
actors/Enemies/Spider/ik_target.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends Marker3D
|
||||
class_name SpiderIKTarget
|
||||
|
||||
@export var step_target: Marker3D
|
||||
@export var step_distance: float = 1.75
|
||||
@export var tween_duration: float = 0.45
|
||||
|
||||
@export var adjacent_target: SpiderIKTarget
|
||||
@export var opposite_target: SpiderIKTarget
|
||||
|
||||
var spider_body: CharacterBody3D
|
||||
|
||||
var is_stepping := false
|
||||
var can_step : = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
top_level = true
|
||||
spider_body = get_parent()
|
||||
step_distance = step_distance * owner.scale.x
|
||||
tween_duration = tween_duration * owner.scale.x
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if !is_stepping && !adjacent_target.is_stepping && abs(self.global_position.distance_to(step_target.global_position)) >= step_distance:
|
||||
step()
|
||||
opposite_target.step()
|
||||
|
||||
func step():
|
||||
var target_pos = step_target.global_position
|
||||
var half_way = (global_position + step_target.global_position) /2
|
||||
is_stepping = true
|
||||
|
||||
var t = create_tween()
|
||||
t.tween_property(self,"global_position",half_way + owner.basis.y-Vector3(0,0.45,0)*owner.scale.x,tween_duration / spider_body.velocity.length())
|
||||
t.tween_property(self,"global_position", target_pos,tween_duration / spider_body.velocity.length())
|
||||
t.tween_callback(func(): is_stepping = false)
|
||||
1
actors/Enemies/Spider/ik_target.gd.uid
Normal file
1
actors/Enemies/Spider/ik_target.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b7nx043bbja0u
|
||||
24
actors/Enemies/Spider/mech_spider_base.gd
Normal file
24
actors/Enemies/Spider/mech_spider_base.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends BaseEnemy
|
||||
class_name SpiderEnemy
|
||||
|
||||
var closestPlayerGridPosition: Vector2
|
||||
var distanceClosestPlayer: float
|
||||
var closestPlayer: PlayerCharacter
|
||||
@onready var spiderLight := $SpiderLight
|
||||
@onready var hitBoxTeeth := $HitBox
|
||||
var attackTeeth: Attack = Attack.new()
|
||||
|
||||
func _ready() -> void:
|
||||
attackTeeth.damage = 25.0
|
||||
attackTeeth.trauma = 0.65
|
||||
hitBoxTeeth.attack = attackTeeth
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
closestPlayer = getClosestPlayerOnPathGrid()
|
||||
if !closestPlayer: return
|
||||
closestPlayerGridPosition = Vector2(closestPlayer.global_position.x,closestPlayer.global_position.z)
|
||||
distanceClosestPlayer = (closestPlayer.global_position - global_position).length()
|
||||
baseEnemyIdle(delta)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
baseEnemyPhysics(delta)
|
||||
1
actors/Enemies/Spider/mech_spider_base.gd.uid
Normal file
1
actors/Enemies/Spider/mech_spider_base.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drdkwkfj4rnb8
|
||||
1427
actors/Enemies/Spider/mech_spider_base.tscn
Normal file
1427
actors/Enemies/Spider/mech_spider_base.tscn
Normal file
File diff suppressed because one or more lines are too long
1440
actors/Enemies/Spider/mech_spider_base.tscn9732395635.tmp
Normal file
1440
actors/Enemies/Spider/mech_spider_base.tscn9732395635.tmp
Normal file
File diff suppressed because one or more lines are too long
1440
actors/Enemies/Spider/mech_spider_base.tscn9745725999.tmp
Normal file
1440
actors/Enemies/Spider/mech_spider_base.tscn9745725999.tmp
Normal file
File diff suppressed because one or more lines are too long
14
actors/Enemies/Spider/rotationLock.gd
Normal file
14
actors/Enemies/Spider/rotationLock.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends Skeleton3D
|
||||
|
||||
var bones: Array[int] = [6,11,16,21,26,31,36,41]
|
||||
var boneRotations: Array[Quaternion]
|
||||
|
||||
func _ready() -> void:
|
||||
for bone in bones:
|
||||
boneRotations.push_back(get_bone_pose_rotation(bone))
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var x = 0
|
||||
for bone in bones:
|
||||
set_bone_pose(bone, boneRotations[x])
|
||||
x += 1
|
||||
1
actors/Enemies/Spider/rotationLock.gd.uid
Normal file
1
actors/Enemies/Spider/rotationLock.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://by5f8425fuu8q
|
||||
12
actors/Enemies/Spider/step_ray.gd
Normal file
12
actors/Enemies/Spider/step_ray.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends RayCast3D
|
||||
|
||||
@export var step_target: Marker3D
|
||||
|
||||
func _ready() -> void:
|
||||
step_target.top_level = true
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var col_point = get_collision_point()
|
||||
if col_point:
|
||||
step_target.global_position = col_point + Vector3(0,0.78,0)*owner.scale.x
|
||||
1
actors/Enemies/Spider/step_ray.gd.uid
Normal file
1
actors/Enemies/Spider/step_ray.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bb8gorx3134vp
|
||||
14
actors/Enemies/Spider/step_targets_container.gd
Normal file
14
actors/Enemies/Spider/step_targets_container.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
extends Node3D
|
||||
|
||||
@export var offset: float = 10
|
||||
|
||||
@onready var parent = get_parent_node_3d()
|
||||
@onready var previous_position = parent.global_position
|
||||
func _ready() -> void:
|
||||
offset = offset*owner.scale.x
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var velovity : Vector3 = (owner.global_position - previous_position) * delta
|
||||
global_position = owner.global_position + velovity.normalized() * offset
|
||||
|
||||
previous_position = owner.global_position
|
||||
1
actors/Enemies/Spider/step_targets_container.gd.uid
Normal file
1
actors/Enemies/Spider/step_targets_container.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bodwd2ercb5e2
|
||||
Reference in New Issue
Block a user