mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Mob and NetworkedPlayer now also uses the body script and fixed a nullreference error. Also updated HEADS to get a fix for Voxelman.
This commit is contained in:
parent
b30a02f7b8
commit
1d7a428987
2
HEADS
2
HEADS
@ -1 +1 @@
|
|||||||
{"engine": {"3.2": "ed27b7e6b973eb6be6fdac4439e99a1907b9cb58", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "97f10512f8832394389e1109154b8af34a2ef2c6"}, "entity_spell_system": {"master": "677f138a462b248d45b679a66d0b4cd3ed886ef8"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "af0c4d6586fa4dd7364280df6c4a0a768d9436da"}, "texture_packer": {"master": "b29b499adf570aa7f85af69ef080ff0d5e04afae"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "4ee946963a16bbfdb4dbb5df52134d22aa168041"}, "procedural_animations": {"master": "9ae56c17230ba9c6160777650b2b89eecdc8df9e"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "fast_quadratic_mesh_simplifier": {"master": "f6d3d65cc6ce4dddfc68054164feec1f612ecd1f"}, "props": {"master": "b2bcb5ea6469b19298cd849c1232ddb5ad26f71c"}}
|
{"engine": {"3.2": "ed27b7e6b973eb6be6fdac4439e99a1907b9cb58", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "97f10512f8832394389e1109154b8af34a2ef2c6"}, "entity_spell_system": {"master": "677f138a462b248d45b679a66d0b4cd3ed886ef8"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "233dde39defd6608913da5434d8ef2cbff3bfd42"}, "texture_packer": {"master": "b29b499adf570aa7f85af69ef080ff0d5e04afae"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "4ee946963a16bbfdb4dbb5df52134d22aa168041"}, "procedural_animations": {"master": "9ae56c17230ba9c6160777650b2b89eecdc8df9e"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "fast_quadratic_mesh_simplifier": {"master": "f6d3d65cc6ce4dddfc68054164feec1f612ecd1f"}, "props": {"master": "b2bcb5ea6469b19298cd849c1232ddb5ad26f71c"}}
|
@ -23,6 +23,11 @@
|
|||||||
|
|
||||||
extends KinematicBody
|
extends KinematicBody
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export(float) var max_visible_distance : float = 120 setget set_max_visible_distance
|
||||||
|
var max_visible_distance_squared : float = max_visible_distance * max_visible_distance
|
||||||
|
|
||||||
export(float) var MOUSE_SENSITIVITY : float = 0.05
|
export(float) var MOUSE_SENSITIVITY : float = 0.05
|
||||||
export(String) var world_path : String = "../.."
|
export(String) var world_path : String = "../.."
|
||||||
export(NodePath) var model_path : NodePath = "Rotation_Helper/Model"
|
export(NodePath) var model_path : NodePath = "Rotation_Helper/Model"
|
||||||
@ -36,7 +41,8 @@ const JUMP_SPEED : float = 3.8
|
|||||||
const MAX_SLOPE_ANGLE : float = 40.0
|
const MAX_SLOPE_ANGLE : float = 40.0
|
||||||
const MOUSE_TARGET_MAX_OFFSET : int = 10
|
const MOUSE_TARGET_MAX_OFFSET : int = 10
|
||||||
|
|
||||||
var _on : bool = false
|
var _on : bool = true
|
||||||
|
var _controlled : bool = false
|
||||||
|
|
||||||
var y_rot : float = 0.0
|
var y_rot : float = 0.0
|
||||||
|
|
||||||
@ -51,6 +57,7 @@ var mouse_right_down : bool = false
|
|||||||
var touchpad_dir : Vector2 = Vector2()
|
var touchpad_dir : Vector2 = Vector2()
|
||||||
var mouse_down_delta : Vector2 = Vector2()
|
var mouse_down_delta : Vector2 = Vector2()
|
||||||
var queued_camera_rotaions : Vector2 = Vector2()
|
var queued_camera_rotaions : Vector2 = Vector2()
|
||||||
|
var target_movement_direction : Vector2 = Vector2()
|
||||||
|
|
||||||
var key_left : bool = false
|
var key_left : bool = false
|
||||||
var key_right : bool = false
|
var key_right : bool = false
|
||||||
@ -72,6 +79,10 @@ var animation_run : bool = false
|
|||||||
var moving : bool = false
|
var moving : bool = false
|
||||||
var casting_anim : bool = false
|
var casting_anim : bool = false
|
||||||
|
|
||||||
|
var sleep : bool = false
|
||||||
|
var dead : bool = false
|
||||||
|
var death_timer : float = 0
|
||||||
|
|
||||||
var last_mouse_over : Entity = null
|
var last_mouse_over : Entity = null
|
||||||
|
|
||||||
var world : VoxelWorld = null
|
var world : VoxelWorld = null
|
||||||
@ -81,8 +92,8 @@ var model_rotation_node : Spatial
|
|||||||
var character_skeleton : CharacterSkeleton3D
|
var character_skeleton : CharacterSkeleton3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
camera = $CameraPivot/Camera as Camera
|
camera = get_node_or_null("CameraPivot/Camera") as Camera
|
||||||
camera_pivot = $CameraPivot as Spatial
|
camera_pivot = get_node_or_null("CameraPivot") as Spatial
|
||||||
|
|
||||||
model_rotation_node = get_node(model_path)
|
model_rotation_node = get_node(model_path)
|
||||||
character_skeleton = get_node(character_skeleton_path)
|
character_skeleton = get_node(character_skeleton_path)
|
||||||
@ -91,17 +102,54 @@ func _ready() -> void:
|
|||||||
entity.connect("ccast_failed", self, "_con_cast_failed")
|
entity.connect("ccast_failed", self, "_con_cast_failed")
|
||||||
entity.connect("ccast_finished", self, "_con_cast_finished")
|
entity.connect("ccast_finished", self, "_con_cast_finished")
|
||||||
entity.connect("cspell_cast_success", self, "_con_spell_cast_success")
|
entity.connect("cspell_cast_success", self, "_con_spell_cast_success")
|
||||||
|
entity.connect("sdied", self, "on_sdied")
|
||||||
|
|
||||||
|
|
||||||
animation_tree = character_skeleton.get_animation_tree()
|
animation_tree = character_skeleton.get_animation_tree()
|
||||||
|
|
||||||
if animation_tree != null:
|
if animation_tree != null:
|
||||||
anim_node_state_machine = animation_tree["parameters/playback"]
|
anim_node_state_machine = animation_tree["parameters/playback"]
|
||||||
|
|
||||||
|
animation_tree["parameters/run-loop/blend_position"] = Vector2(0, -1)
|
||||||
|
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
world = get_node(world_path) as VoxelWorld
|
world = get_node(world_path) as VoxelWorld
|
||||||
|
set_process(true)
|
||||||
set_physics_process(true)
|
set_physics_process(true)
|
||||||
get_parent().connect("isc_controlled_changed", self, "on_c_controlled_changed")
|
get_parent().connect("isc_controlled_changed", self, "on_c_controlled_changed")
|
||||||
|
|
||||||
|
func _process(delta : float) -> void:
|
||||||
|
if entity.ai_state == EntityEnums.AI_STATE_OFF:
|
||||||
|
return
|
||||||
|
|
||||||
|
var camera : Camera = get_tree().get_root().get_camera() as Camera
|
||||||
|
|
||||||
|
if camera == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
var cam_pos : Vector3 = camera.global_transform.xform(Vector3())
|
||||||
|
var dstv : Vector3 = cam_pos - translation
|
||||||
|
dstv.y = 0
|
||||||
|
var dst : float = dstv.length_squared()
|
||||||
|
|
||||||
|
if dst > max_visible_distance_squared:
|
||||||
|
if visible:
|
||||||
|
hide()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# var lod_level : int = int(dst / max_visible_distance_squared * 3.0)
|
||||||
|
|
||||||
|
if dst < 400: #20^2
|
||||||
|
entity.get_character_skeleton().set_lod_level(0)
|
||||||
|
elif dst > 400 and dst < 900: #20^2, 30^2
|
||||||
|
entity.get_character_skeleton().set_lod_level(1)
|
||||||
|
else:
|
||||||
|
entity.get_character_skeleton().set_lod_level(2)
|
||||||
|
|
||||||
|
if not visible:
|
||||||
|
show()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta : float) -> void:
|
func _physics_process(delta : float) -> void:
|
||||||
if not _on:
|
if not _on:
|
||||||
@ -110,8 +158,21 @@ func _physics_process(delta : float) -> void:
|
|||||||
if world.initial_generation:
|
if world.initial_generation:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if entity.sentity_data == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
|
|
||||||
|
if entity.ai_state == EntityEnums.AI_STATE_OFF:
|
||||||
process_input(delta)
|
process_input(delta)
|
||||||
process_movement(delta)
|
process_movement_player(delta)
|
||||||
|
else:
|
||||||
|
if world != null:
|
||||||
|
if not world.is_position_walkable(transform.origin):
|
||||||
|
return
|
||||||
|
|
||||||
|
process_movement_mob(delta)
|
||||||
|
|
||||||
func process_input(delta: float) -> void:
|
func process_input(delta: float) -> void:
|
||||||
var key_dir : Vector2 = Vector2()
|
var key_dir : Vector2 = Vector2()
|
||||||
@ -161,7 +222,7 @@ func process_input(delta: float) -> void:
|
|||||||
rotate_delta(camera_pivot.get_y_rot())
|
rotate_delta(camera_pivot.get_y_rot())
|
||||||
camera_pivot.set_y_rot(0.0)
|
camera_pivot.set_y_rot(0.0)
|
||||||
|
|
||||||
func process_movement(delta : float) -> void:
|
func process_movement_player(delta : float) -> void:
|
||||||
var state : int = entity.getc_state()
|
var state : int = entity.getc_state()
|
||||||
|
|
||||||
if state & EntityEnums.ENTITY_STATE_TYPE_FLAG_ROOT != 0 or state & EntityEnums.ENTITY_STATE_TYPE_FLAG_STUN != 0:
|
if state & EntityEnums.ENTITY_STATE_TYPE_FLAG_ROOT != 0 or state & EntityEnums.ENTITY_STATE_TYPE_FLAG_STUN != 0:
|
||||||
@ -211,6 +272,89 @@ func process_movement(delta : float) -> void:
|
|||||||
sset_position(translation, rotation)
|
sset_position(translation, rotation)
|
||||||
|
|
||||||
|
|
||||||
|
func process_movement_mob(delta : float) -> void:
|
||||||
|
if entity.starget != null:
|
||||||
|
look_at(entity.starget.get_body().translation, Vector3(0, 1, 0))
|
||||||
|
|
||||||
|
var state : int = entity.getc_state()
|
||||||
|
|
||||||
|
if state & EntityEnums.ENTITY_STATE_TYPE_FLAG_ROOT != 0 or state & EntityEnums.ENTITY_STATE_TYPE_FLAG_STUN != 0:
|
||||||
|
moving = false
|
||||||
|
return
|
||||||
|
|
||||||
|
if target_movement_direction.length_squared() > 0.1:
|
||||||
|
if anim_node_state_machine != null and not animation_run:
|
||||||
|
anim_node_state_machine.travel("run-loop")
|
||||||
|
animation_run = true
|
||||||
|
|
||||||
|
target_movement_direction = target_movement_direction.normalized()
|
||||||
|
moving = true
|
||||||
|
else:
|
||||||
|
if anim_node_state_machine != null and animation_run:
|
||||||
|
anim_node_state_machine.travel("idle-loop")
|
||||||
|
animation_run = false
|
||||||
|
|
||||||
|
moving = false
|
||||||
|
|
||||||
|
if target_movement_direction.x > 0.1 or target_movement_direction.y > 0.1 or target_movement_direction.x < -0.1 or target_movement_direction.y < -0.1:
|
||||||
|
y_rot = Vector2(0, 1).angle_to(target_movement_direction)
|
||||||
|
|
||||||
|
var forward : Vector3 = Vector3(0, 0, 1).rotated(Vector3(0, 1, 0), deg2rad(y_rot))
|
||||||
|
var right : Vector3 = forward.cross(Vector3(0, 1, 0)) * -target_movement_direction.x
|
||||||
|
forward *= target_movement_direction.y #only potentially make it zero after getting the right vector
|
||||||
|
|
||||||
|
dir = forward
|
||||||
|
dir += right
|
||||||
|
|
||||||
|
if dir.length_squared() > 0.1:
|
||||||
|
dir = dir.normalized()
|
||||||
|
|
||||||
|
moving = true
|
||||||
|
else:
|
||||||
|
dir = Vector3()
|
||||||
|
moving = false
|
||||||
|
|
||||||
|
if not moving and sleep:
|
||||||
|
return
|
||||||
|
|
||||||
|
if moving and sleep:
|
||||||
|
sleep = false
|
||||||
|
|
||||||
|
vel.y += delta * GRAVITY
|
||||||
|
|
||||||
|
var hvel : Vector3 = vel
|
||||||
|
hvel.y = 0
|
||||||
|
|
||||||
|
var target : Vector3 = dir
|
||||||
|
target *= entity.get_speed().ccurrent
|
||||||
|
|
||||||
|
var accel
|
||||||
|
if dir.dot(hvel) > 0:
|
||||||
|
accel = ACCEL
|
||||||
|
else:
|
||||||
|
accel = DEACCEL
|
||||||
|
|
||||||
|
hvel = hvel.linear_interpolate(target, accel * delta) as Vector3
|
||||||
|
vel.x = hvel.x
|
||||||
|
vel.z = hvel.z
|
||||||
|
|
||||||
|
var facing : Vector3 = vel
|
||||||
|
facing.y = 0
|
||||||
|
|
||||||
|
vel = move_and_slide(vel, Vector3(0,1,0), false, 4, deg2rad(MAX_SLOPE_ANGLE))
|
||||||
|
sset_position(translation, rotation)
|
||||||
|
|
||||||
|
if vel.length_squared() < 0.12:
|
||||||
|
sleep = true
|
||||||
|
|
||||||
|
if translation.y < -50.0:
|
||||||
|
print("killed mob with fall damage")
|
||||||
|
var sdi : SpellDamageInfo = SpellDamageInfo.new()
|
||||||
|
sdi.damage_source_type = SpellDamageInfo.DAMAGE_SOURCE_UNKNOWN
|
||||||
|
sdi.damage = 999999999
|
||||||
|
entity.stake_damage(sdi)
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if not cursor_grabbed:
|
if not cursor_grabbed:
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
@ -319,6 +463,7 @@ func rotate_delta(x_delta : float) -> void:
|
|||||||
|
|
||||||
rotation_degrees = Vector3(0.0, y_rot, 0.0)
|
rotation_degrees = Vector3(0.0, y_rot, 0.0)
|
||||||
|
|
||||||
|
|
||||||
func target(position : Vector2):
|
func target(position : Vector2):
|
||||||
var from = camera.project_ray_origin(position)
|
var from = camera.project_ray_origin(position)
|
||||||
var to = from + camera.project_ray_normal(position) * ray_length
|
var to = from + camera.project_ray_normal(position) * ray_length
|
||||||
@ -379,21 +524,16 @@ func queue_camera_rotation(rot : Vector2) -> void:
|
|||||||
queued_camera_rotaions += rot
|
queued_camera_rotaions += rot
|
||||||
|
|
||||||
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
|
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
|
||||||
if get_network_master() != 1:
|
|
||||||
print(str(get_network_master()) + "psset")
|
|
||||||
|
|
||||||
if multiplayer.network_peer and multiplayer.is_network_server():
|
if multiplayer.network_peer and multiplayer.is_network_server():
|
||||||
entity.vrpc("cset_position", position, rotation)
|
entity.vrpc("cset_position", position, rotation)
|
||||||
|
|
||||||
|
if _controlled:
|
||||||
cset_position(position, rotation)
|
cset_position(position, rotation)
|
||||||
|
|
||||||
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
||||||
if get_network_master() != 1:
|
|
||||||
print(str(get_network_master()) + " pcset")
|
|
||||||
translation = position
|
translation = position
|
||||||
rotation = rotation
|
rotation = rotation
|
||||||
|
|
||||||
#func _setup():
|
|
||||||
# setup_actionbars()
|
|
||||||
|
|
||||||
func _con_cast_started(info):
|
func _con_cast_started(info):
|
||||||
if anim_node_state_machine != null and not casting_anim:
|
if anim_node_state_machine != null and not casting_anim:
|
||||||
@ -428,7 +568,29 @@ func _con_spell_cast_success(info):
|
|||||||
|
|
||||||
func on_c_controlled_changed(val):
|
func on_c_controlled_changed(val):
|
||||||
#create camera and pivot if true
|
#create camera and pivot if true
|
||||||
_on = val
|
_controlled = val
|
||||||
|
|
||||||
set_physics_process(val)
|
# set_physics_process(val)
|
||||||
|
set_process_input(val)
|
||||||
|
set_process_unhandled_input(val)
|
||||||
|
|
||||||
|
func on_sdied(entity):
|
||||||
|
if dead:
|
||||||
|
return
|
||||||
|
|
||||||
|
dead = true
|
||||||
|
|
||||||
|
anim_node_state_machine.travel("dead")
|
||||||
|
|
||||||
|
set_physics_process(false)
|
||||||
|
|
||||||
|
remote func set_position(position : Vector3, rotation : Vector3) -> void:
|
||||||
|
if get_tree().is_network_server():
|
||||||
|
rpc("set_position", position, rotation)
|
||||||
|
|
||||||
|
|
||||||
|
func set_max_visible_distance(var value : float) -> void:
|
||||||
|
max_visible_distance_squared = value * value
|
||||||
|
|
||||||
|
max_visible_distance = value
|
||||||
|
|
||||||
|
@ -23,52 +23,14 @@ extends Entity
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
#export (String) var map_path : String
|
|
||||||
export(float) var max_visible_distance : float = 120 setget set_max_visible_distance
|
|
||||||
var max_visible_distance_squared : float = max_visible_distance * max_visible_distance
|
|
||||||
|
|
||||||
const ray_length = 1000
|
|
||||||
const ACCEL : float = 100.0
|
|
||||||
const DEACCEL : float = 100.0
|
|
||||||
const GRAVITY : float = -24.8
|
|
||||||
const JUMP_SPEED : float = 3.8
|
|
||||||
const MAX_SLOPE_ANGLE : float = 40.0
|
|
||||||
|
|
||||||
var _on : bool = true
|
|
||||||
|
|
||||||
var y_rot : float = 0.0
|
|
||||||
|
|
||||||
var vel : Vector3 = Vector3()
|
|
||||||
var dir : Vector3 = Vector3()
|
|
||||||
var target_movement_direction : Vector2 = Vector2()
|
|
||||||
|
|
||||||
var animation_tree : AnimationTree
|
|
||||||
var anim_node_state_machine : AnimationNodeStateMachinePlayback = null
|
|
||||||
var animation_run : bool = false
|
|
||||||
|
|
||||||
var moving : bool = false
|
|
||||||
var sleep : bool = false
|
|
||||||
var dead : bool = false
|
var dead : bool = false
|
||||||
var death_timer : float = 0
|
var death_timer : float = 0
|
||||||
|
|
||||||
var _world : VoxelWorld = null
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
animation_tree = get_character_skeleton().get_animation_tree()
|
|
||||||
|
|
||||||
if animation_tree != null:
|
|
||||||
anim_node_state_machine = animation_tree["parameters/playback"]
|
|
||||||
|
|
||||||
animation_tree["parameters/run-loop/blend_position"] = Vector2(0, -1)
|
|
||||||
|
|
||||||
ai_state = EntityEnums.AI_STATE_PATROL
|
ai_state = EntityEnums.AI_STATE_PATROL
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
_world = get_node("..") as VoxelWorld
|
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
set_physics_process(true)
|
|
||||||
|
|
||||||
|
|
||||||
func _process(delta : float) -> void:
|
func _process(delta : float) -> void:
|
||||||
if dead:
|
if dead:
|
||||||
@ -79,142 +41,6 @@ func _process(delta : float) -> void:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
var camera : Camera = get_tree().get_root().get_camera() as Camera
|
|
||||||
|
|
||||||
if camera == null:
|
|
||||||
return
|
|
||||||
|
|
||||||
var cam_pos : Vector3 = camera.global_transform.xform(Vector3())
|
|
||||||
var dstv : Vector3 = cam_pos - get_body().translation
|
|
||||||
dstv.y = 0
|
|
||||||
var dst : float = dstv.length_squared()
|
|
||||||
|
|
||||||
if dst > max_visible_distance_squared:
|
|
||||||
if get_body().visible:
|
|
||||||
get_body().hide()
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
# var lod_level : int = int(dst / max_visible_distance_squared * 3.0)
|
|
||||||
|
|
||||||
if dst < 400: #20^2
|
|
||||||
get_character_skeleton().set_lod_level(0)
|
|
||||||
elif dst > 400 and dst < 900: #20^2, 30^2
|
|
||||||
get_character_skeleton().set_lod_level(1)
|
|
||||||
else:
|
|
||||||
get_character_skeleton().set_lod_level(2)
|
|
||||||
|
|
||||||
if not get_body().visible:
|
|
||||||
get_body().show()
|
|
||||||
|
|
||||||
func _physics_process(delta : float) -> void:
|
|
||||||
if not _on:
|
|
||||||
return
|
|
||||||
|
|
||||||
if sentity_data == null:
|
|
||||||
return
|
|
||||||
|
|
||||||
if dead:
|
|
||||||
return
|
|
||||||
|
|
||||||
if _world != null:
|
|
||||||
if not _world.is_position_walkable(get_body().transform.origin):
|
|
||||||
return
|
|
||||||
|
|
||||||
process_movement(delta)
|
|
||||||
|
|
||||||
func process_movement(delta : float) -> void:
|
|
||||||
if starget != null:
|
|
||||||
get_body().look_at(starget.get_body().translation, Vector3(0, 1, 0))
|
|
||||||
|
|
||||||
var state : int = getc_state()
|
|
||||||
|
|
||||||
if state & EntityEnums.ENTITY_STATE_TYPE_FLAG_ROOT != 0 or state & EntityEnums.ENTITY_STATE_TYPE_FLAG_STUN != 0:
|
|
||||||
moving = false
|
|
||||||
return
|
|
||||||
|
|
||||||
if target_movement_direction.length_squared() > 0.1:
|
|
||||||
if anim_node_state_machine != null and not animation_run:
|
|
||||||
anim_node_state_machine.travel("run-loop")
|
|
||||||
animation_run = true
|
|
||||||
|
|
||||||
target_movement_direction = target_movement_direction.normalized()
|
|
||||||
moving = true
|
|
||||||
else:
|
|
||||||
if anim_node_state_machine != null and animation_run:
|
|
||||||
anim_node_state_machine.travel("idle-loop")
|
|
||||||
animation_run = false
|
|
||||||
|
|
||||||
moving = false
|
|
||||||
|
|
||||||
if target_movement_direction.x > 0.1 or target_movement_direction.y > 0.1 or target_movement_direction.x < -0.1 or target_movement_direction.y < -0.1:
|
|
||||||
y_rot = Vector2(0, 1).angle_to(target_movement_direction)
|
|
||||||
|
|
||||||
var forward : Vector3 = Vector3(0, 0, 1).rotated(Vector3(0, 1, 0), deg2rad(y_rot))
|
|
||||||
var right : Vector3 = forward.cross(Vector3(0, 1, 0)) * -target_movement_direction.x
|
|
||||||
forward *= target_movement_direction.y #only potentially make it zero after getting the right vector
|
|
||||||
|
|
||||||
dir = forward
|
|
||||||
dir += right
|
|
||||||
|
|
||||||
if dir.length_squared() > 0.1:
|
|
||||||
dir = dir.normalized()
|
|
||||||
|
|
||||||
moving = true
|
|
||||||
else:
|
|
||||||
dir = Vector3()
|
|
||||||
moving = false
|
|
||||||
|
|
||||||
if not moving and sleep:
|
|
||||||
return
|
|
||||||
|
|
||||||
if moving and sleep:
|
|
||||||
sleep = false
|
|
||||||
|
|
||||||
vel.y += delta * GRAVITY
|
|
||||||
|
|
||||||
var hvel : Vector3 = vel
|
|
||||||
hvel.y = 0
|
|
||||||
|
|
||||||
var target : Vector3 = dir
|
|
||||||
target *= get_speed().ccurrent
|
|
||||||
|
|
||||||
var accel
|
|
||||||
if dir.dot(hvel) > 0:
|
|
||||||
accel = ACCEL
|
|
||||||
else:
|
|
||||||
accel = DEACCEL
|
|
||||||
|
|
||||||
hvel = hvel.linear_interpolate(target, accel * delta) as Vector3
|
|
||||||
vel.x = hvel.x
|
|
||||||
vel.z = hvel.z
|
|
||||||
|
|
||||||
var facing : Vector3 = vel
|
|
||||||
facing.y = 0
|
|
||||||
|
|
||||||
vel = get_body().move_and_slide(vel, Vector3(0,1,0), false, 4, deg2rad(MAX_SLOPE_ANGLE))
|
|
||||||
sset_position(get_body().translation, get_body().rotation)
|
|
||||||
|
|
||||||
if vel.length_squared() < 0.12:
|
|
||||||
sleep = true
|
|
||||||
|
|
||||||
if get_body().translation.y < -50.0:
|
|
||||||
print("killed mob with fall damage")
|
|
||||||
var sdi : SpellDamageInfo = SpellDamageInfo.new()
|
|
||||||
sdi.damage_source_type = SpellDamageInfo.DAMAGE_SOURCE_UNKNOWN
|
|
||||||
sdi.damage = 999999999
|
|
||||||
stake_damage(sdi)
|
|
||||||
|
|
||||||
func rotate_delta(x_delta : float) -> void:
|
|
||||||
y_rot += x_delta
|
|
||||||
|
|
||||||
if y_rot > 360:
|
|
||||||
y_rot = 0
|
|
||||||
if y_rot < 0:
|
|
||||||
y_rot = 360
|
|
||||||
|
|
||||||
get_body().rotation_degrees = Vector3(0.0, y_rot, 0.0)
|
|
||||||
|
|
||||||
func sstart_attack(entity : Entity) -> void:
|
func sstart_attack(entity : Entity) -> void:
|
||||||
ai_state = EntityEnums.AI_STATE_ATTACK
|
ai_state = EntityEnums.AI_STATE_ATTACK
|
||||||
|
|
||||||
@ -260,14 +86,9 @@ func _son_death():
|
|||||||
sentity_interaction_type = EntityEnums.ENITIY_INTERACTION_TYPE_LOOT
|
sentity_interaction_type = EntityEnums.ENITIY_INTERACTION_TYPE_LOOT
|
||||||
ai_state = EntityEnums.AI_STATE_OFF
|
ai_state = EntityEnums.AI_STATE_OFF
|
||||||
|
|
||||||
anim_node_state_machine.travel("dead")
|
|
||||||
|
|
||||||
# set_process(false)
|
func set_position(position : Vector3, rotation : Vector3) -> void:
|
||||||
set_physics_process(false)
|
get_body().set_position(position, rotation)
|
||||||
|
|
||||||
remote func set_position(position : Vector3, rotation : Vector3) -> void:
|
|
||||||
if get_tree().is_network_server():
|
|
||||||
rpc("set_position", position, rotation)
|
|
||||||
|
|
||||||
func _son_damage_dealt(data):
|
func _son_damage_dealt(data):
|
||||||
if ai_state != EntityEnums.AI_STATE_ATTACK and data.dealer != self:
|
if ai_state != EntityEnums.AI_STATE_ATTACK and data.dealer != self:
|
||||||
@ -280,18 +101,6 @@ func _con_damage_dealt(info : SpellDamageInfo) -> void:
|
|||||||
func _con_heal_dealt(info : SpellHealInfo) -> void:
|
func _con_heal_dealt(info : SpellHealInfo) -> void:
|
||||||
WorldNumbers.heal(get_body().translation, 1.6, info.heal, info.crit)
|
WorldNumbers.heal(get_body().translation, 1.6, info.heal, info.crit)
|
||||||
|
|
||||||
func _moved() -> void:
|
|
||||||
if sis_casting():
|
|
||||||
sfail_cast()
|
|
||||||
|
|
||||||
func set_max_visible_distance(var value : float) -> void:
|
|
||||||
max_visible_distance_squared = value * value
|
|
||||||
|
|
||||||
max_visible_distance = value
|
|
||||||
|
|
||||||
#func _setup():
|
|
||||||
# sentity_name = sentity_data.text_name
|
|
||||||
|
|
||||||
func _son_xp_gained(value : int) -> void:
|
func _son_xp_gained(value : int) -> void:
|
||||||
if not ESS.get_resource_db().get_xp_data().can_character_level_up(gets_character_level()):
|
if not ESS.get_resource_db().get_xp_data().can_character_level_up(gets_character_level()):
|
||||||
return
|
return
|
||||||
@ -347,12 +156,3 @@ func refresh_spells(value: int):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
func sset_position(position : Vector3, rotation : Vector3) -> void:
|
|
||||||
if multiplayer.network_peer and multiplayer.is_network_server():
|
|
||||||
# cset_position(position, rotation)
|
|
||||||
vrpc("cset_position", position, rotation)
|
|
||||||
|
|
||||||
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
|
||||||
get_body().translation = position
|
|
||||||
get_body().rotation = rotation
|
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://data/models/armature_model_orig_v2.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://data/models/armature_model_orig_v2.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://player/Mob.gd" type="Script" id=2]
|
[ext_resource path="res://player/Mob.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://ui/nameplates/NamePlate.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://ui/nameplates/NamePlate.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://player/Body.gd" type="Script" id=4]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape" id=1]
|
[sub_resource type="CapsuleShape" id=1]
|
||||||
radius = 0.266582
|
radius = 0.266582
|
||||||
@ -17,12 +18,12 @@ extents = Vector3( 0.216228, 0.0681041, 0.183397 )
|
|||||||
body_path = NodePath("Body")
|
body_path = NodePath("Body")
|
||||||
character_skeleton_path = NodePath("Body/Rotation_Helper/Model/character")
|
character_skeleton_path = NodePath("Body/Rotation_Helper/Model/character")
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
max_visible_distance = 100.0
|
|
||||||
|
|
||||||
[node name="NamePlate" parent="." instance=ExtResource( 3 )]
|
[node name="NamePlate" parent="." instance=ExtResource( 3 )]
|
||||||
max_distance = 50.0
|
max_distance = 50.0
|
||||||
|
|
||||||
[node name="Body" type="KinematicBody" parent="."]
|
[node name="Body" type="KinematicBody" parent="."]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="Body_CollisionShape" type="CollisionShape" parent="Body"]
|
[node name="Body_CollisionShape" type="CollisionShape" parent="Body"]
|
||||||
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.73, 0 )
|
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.73, 0 )
|
||||||
@ -38,3 +39,5 @@ transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 0, 0
|
|||||||
[node name="Model" type="Spatial" parent="Body/Rotation_Helper"]
|
[node name="Model" type="Spatial" parent="Body/Rotation_Helper"]
|
||||||
|
|
||||||
[node name="character" parent="Body/Rotation_Helper/Model" instance=ExtResource( 1 )]
|
[node name="character" parent="Body/Rotation_Helper/Model" instance=ExtResource( 1 )]
|
||||||
|
refresh_in_editor = false
|
||||||
|
use_lod = true
|
||||||
|
@ -24,46 +24,3 @@ class_name NetworkedPlayerGD
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
const ray_length = 1000
|
|
||||||
const ACCEL : float = 100.0
|
|
||||||
const DEACCEL : float = 100.0
|
|
||||||
const GRAVITY : float = -24.8
|
|
||||||
const JUMP_SPEED : float = 3.8
|
|
||||||
const MAX_SLOPE_ANGLE : float = 40.0
|
|
||||||
const MOUSE_TARGET_MAX_OFFSET : int = 10
|
|
||||||
|
|
||||||
var y_rot : float = 0.0
|
|
||||||
|
|
||||||
var animation_tree : AnimationTree
|
|
||||||
var anim_node_state_machine : AnimationNodeStateMachinePlayback = null
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
animation_tree = get_character_skeleton().get_animation_tree()
|
|
||||||
|
|
||||||
if animation_tree != null:
|
|
||||||
anim_node_state_machine = animation_tree["parameters/playback"]
|
|
||||||
|
|
||||||
|
|
||||||
func rotate_delta(x_delta : float) -> void:
|
|
||||||
y_rot += x_delta
|
|
||||||
|
|
||||||
if y_rot > 360:
|
|
||||||
y_rot = 0
|
|
||||||
if y_rot < 0:
|
|
||||||
y_rot = 360
|
|
||||||
|
|
||||||
get_body().rotation_degrees = Vector3(0.0, y_rot, 0.0)
|
|
||||||
|
|
||||||
remote func sset_position(position : Vector3, rotation : Vector3) -> void:
|
|
||||||
if multiplayer.network_peer and multiplayer.is_network_server():
|
|
||||||
cset_position(position, rotation)
|
|
||||||
vrpc("cset_position", position, rotation)
|
|
||||||
|
|
||||||
remote func cset_position(position : Vector3, rotation : Vector3) -> void:
|
|
||||||
get_body().translation = position
|
|
||||||
get_body().rotation = rotation
|
|
||||||
|
|
||||||
func _moved() -> void:
|
|
||||||
if sis_casting():
|
|
||||||
sfail_cast()
|
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://player/NetworkedPlayer.gd" type="Script" id=1]
|
[ext_resource path="res://player/NetworkedPlayer.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://data/models/armature_model_orig_v2.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://data/models/armature_model_orig_v2.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://ui/nameplates/NamePlate.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://ui/nameplates/NamePlate.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://player/Body.gd" type="Script" id=4]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape" id=1]
|
[sub_resource type="CapsuleShape" id=1]
|
||||||
radius = 0.266582
|
radius = 0.266582
|
||||||
@ -17,6 +18,7 @@ character_skeleton_path = NodePath("Body/Rotation_Helper/Model/character")
|
|||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Body" type="KinematicBody" parent="."]
|
[node name="Body" type="KinematicBody" parent="."]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
[node name="Body_CollisionShape" type="CollisionShape" parent="Body"]
|
[node name="Body_CollisionShape" type="CollisionShape" parent="Body"]
|
||||||
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.8, 0 )
|
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.8, 0 )
|
||||||
|
@ -76,7 +76,7 @@ func attack(delta):
|
|||||||
|
|
||||||
if target == null:
|
if target == null:
|
||||||
owner.ai_state = EntityEnums.AI_STATE_REGENERATE
|
owner.ai_state = EntityEnums.AI_STATE_REGENERATE
|
||||||
owner.target_movement_direction = Vector2()
|
owner.get_body().target_movement_direction = Vector2()
|
||||||
return
|
return
|
||||||
|
|
||||||
var cast : bool = false
|
var cast : bool = false
|
||||||
@ -116,16 +116,16 @@ func attack(delta):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if owner.sis_casting():
|
if owner.sis_casting():
|
||||||
owner.target_movement_direction = Vector2()
|
owner.get_body().target_movement_direction = Vector2()
|
||||||
return
|
return
|
||||||
|
|
||||||
owner.target_movement_direction = Vector2()
|
owner.get_body().target_movement_direction = Vector2()
|
||||||
|
|
||||||
var dir : Vector3 = target.get_body().translation - owner.get_body().translation
|
var dir : Vector3 = target.get_body().translation - owner.get_body().translation
|
||||||
var l = dir.length()
|
var l = dir.length()
|
||||||
|
|
||||||
if l > 2.5:
|
if l > 2.5:
|
||||||
owner.target_movement_direction = Vector2(dir.x, dir.z)
|
owner.get_body().target_movement_direction = Vector2(dir.x, dir.z)
|
||||||
|
|
||||||
func sort_spells_by_rank(a, b):
|
func sort_spells_by_rank(a, b):
|
||||||
if a == null or b == null:
|
if a == null or b == null:
|
||||||
|
@ -62,6 +62,7 @@ func on_visibility_changed():
|
|||||||
if visible:
|
if visible:
|
||||||
refresh()
|
refresh()
|
||||||
else:
|
else:
|
||||||
|
if target_bag != null:
|
||||||
target_bag.disconnect("item_removed", self, "on_item_removed")
|
target_bag.disconnect("item_removed", self, "on_item_removed")
|
||||||
target_bag = null
|
target_bag = null
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user