This commit is contained in:
AleaJactaEst 2021-03-23 23:24:40 +01:00
parent 70f3ae38c6
commit 4f72931cac
88 changed files with 36020 additions and 270 deletions

View file

@ -0,0 +1,25 @@
extends Spatial
signal animation_finished( anim_name )
signal limb_body_entered( limb, body )
func _on_AnimationPlayer_animation_finished(anim_name):
emit_signal( "animation_finished", anim_name )
func _on_limb_blue_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )
func _on_limb_pink_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )
func _on_limb_red_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )
func _on_limb_yellow_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )
func _on_limb_green_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )
func _on_limb_cyan_area_body_entered(body):
emit_signal( "limb_body_entered", Datas.Cloth.LIMB.torso, body )

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,22 @@
extends Spatial
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func play( anim_name, speed = 1.0 ):
for child in $body_parts.get_children():
child.get_node( "Arche/AnimationPlayer" ).playback_speed = speed
if child.get_node( "Arche/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "Arche/AnimationPlayer" ).play( anim_name )

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,71 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/creatures/arche/arche.gltf" type="PackedScene" id=1]
[sub_resource type="SphereShape" id=1]
radius = 0.2
[sub_resource type="SphereShape" id=2]
radius = 0.2
[sub_resource type="SphereShape" id=3]
radius = 0.2
[sub_resource type="SphereShape" id=4]
radius = 0.2
[sub_resource type="SphereShape" id=5]
radius = 0.2
[sub_resource type="SphereShape" id=6]
radius = 0.2
[node name="arche" instance=ExtResource( 1 )]
[node name="BoneArcheBleue" parent="Arche/Bone" index="0"]
transform = Transform( 0.707107, 0.707107, -8.9407e-08, 8.9407e-08, 1.19209e-07, 1, 0.707107, -0.707107, 5.96046e-08, 0.7, 0.4, -1.74846e-08 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheBleue/ArcheBleue" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheBleue/ArcheBleue/area" index="0"]
shape = SubResource( 1 )
[node name="BoneArcheRose" parent="Arche/Bone" index="1"]
transform = Transform( -0.843489, -0.537147, 1.19209e-07, 0, 1.19209e-07, 1, -0.537147, 0.843489, -1.19209e-07, -0.0976257, 0.899057, 0.0216616 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheRose/ArcheRose" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheRose/ArcheRose/area" index="0"]
shape = SubResource( 2 )
[node name="BoneArcheRouge" parent="Arche/Bone" index="2"]
transform = Transform( 0.906155, -0.422946, 0, -4.47035e-08, 0, 1, -0.422946, -0.906155, 0, 0.034168, 1.26493, -0.0939817 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheRouge/ArcheRouge" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheRouge/ArcheRouge/area" index="0"]
shape = SubResource( 3 )
[node name="BoneArcheJaune" parent="Arche/Bone" index="3"]
transform = Transform( -0.129988, 0.991516, 0, 0, 0, 1, 0.991516, 0.129988, 0, 0.0609192, 1.39999, 0.0793022 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheJaune/ArcheJaune" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheJaune/ArcheJaune/area" index="0"]
shape = SubResource( 4 )
[node name="BoneArcheVert" parent="Arche/Bone" index="4"]
transform = Transform( -0.981572, 0.191092, -3.27826e-07, -2.98023e-07, 1.78814e-07, 1, 0.191092, 0.981572, -1.19209e-07, -0.391267, 1.26819, 0.58044 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheVert/ArcheVert" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheVert/ArcheVert/area" index="0"]
shape = SubResource( 5 )
[node name="BoneArcheCyan" parent="Arche/Bone" index="5"]
transform = Transform( 0.34168, -0.939817, 2.98023e-08, -2.98023e-08, 1.19209e-07, 1, -0.939817, -0.34168, 0, -0.296062, 0.904706, -0.634308 )
[node name="area" type="Area" parent="Arche/Bone/BoneArcheCyan/ArcheCyan" index="0"]
[node name="collision_shape" type="CollisionShape" parent="Arche/Bone/BoneArcheCyan/ArcheCyan/area" index="0"]
shape = SubResource( 6 )

View file

@ -0,0 +1,302 @@
extends KinematicBody
signal equip( p_slot, p_item )
signal unequip( p_slot )
var character = null
var rotation_speed_factor = 0.01
var move_speed = 2.5
var run_speed = 5.0
var max_speed = 12.0
export var gravity = -9.0
var velocity: = Vector3.ZERO
var is_running = false
var can_turn = false
var ground_contacts = 0
var is_jump_started = false
var is_jumping = false
var jump_strength = 250.0
var is_falling = false
var is_on_ground = true
var is_readying_weapon = false
var is_weapon_ready = false
var can_attack = true
var is_dying = false
var is_dead = false
var direction = Vector3.ZERO
var orientation = 0.0
enum PLAYER_RELATION {
neutre,
friend,
ennemy
}
export( PLAYER_RELATION ) var player_relation = PLAYER_RELATION.neutre
export( String ) var creature_filename = null setget set_creature_filename
func set_creature_filename( p_filename ):
creature_filename = p_filename
self.load_from_name( p_filename )
func _process( delta ):
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = $look_at.global_transform.basis.z * direction.z
var right: Vector3 = $look_at.global_transform.basis.x * direction.x
if forwards:
right = Vector3.ZERO
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# Rotation.
if (self.has_node( "creature" ) and $creature.can_turn()) or self.is_readying_weapon or self.is_weapon_ready:
self.rotate_y( rotation_speed_factor * orientation )
# Movement.
velocity = self.calculate_velocity(velocity, move_direction, delta)
if not self.is_readying_weapon and not self.is_weapon_ready:
if not self.is_jumping and not self.is_jump_started and not self.is_falling:
velocity = self.move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true)
else:
velocity = self.move_and_slide(velocity, Vector3.UP, true)
# Animation.
if self.has_node( "creature" ):
if self.is_dead:
$creature.play( "dead_loop" )
elif self.is_dying:
$creature.play( "dying", 2.0 )
elif self.is_readying_weapon:
$creature.play( "1h_pistol_ready_start" )
elif self.is_weapon_ready:
$creature.play( "1h_pistol_ready_loop" )
elif direction and not self.is_jump_started and not self.is_jumping and not self.is_falling:
if direction.z < 0.0:
if self.is_running:
$creature.play( "run" , 2.0 )
else:
$creature.play( "walk" )
elif direction.z > 0.0:
if self.is_running:
$creature.play_backwards( "run", 2.0 )
else:
$creature.play_backwards( "walk" )
elif direction.x > 0.0:
$creature.play( "strafe_right" )
elif direction.x < 0.0:
$creature.play( "strafe_left" )
elif self.is_jump_started and not self.is_jumping:
$creature.play( "jump_start" )
elif self.is_jumping or self.is_falling:
if not self.is_on_ground:
$creature.play( "jump_loop" )
else:
$creature.play( "jump_end", 2 )
elif not self.orientation == 0.0:
if self.orientation < 0.0:
$creature.play( "turn_right", 2.0 )
elif self.orientation > 0.0:
$creature.play( "turn_left", 2.0 )
else:
$creature.play( "idle" )
func calculate_velocity(
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
# var velocity_new := move_direction
var velocity_new = Vector3.ZERO
if not self.is_jump_started:
velocity_new = move_direction
if self.is_running:
velocity_new *= run_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
if self.is_jumping:
velocity_new.y += self.jump_strength * delta
self.is_jumping = false
self.is_falling = true
if self.is_falling:
velocity_new.x *= 2.0
velocity_new.z *= 2.0
return velocity_new
func load_from_name( p_name, p_emplacement = null ):
var creature = Datas.Creature.new()
creature.set_data( "name", p_name )
creature.load( null, p_emplacement )
if creature.get_data( "race" ) == Globals.RACE.human:
if creature.get_data( "sex" ) == Globals.SEX.female:
self.change_creature( "res://scenes/creatures/human/human_female.tscn" )
elif creature.get_data( "sex" ) == Globals.SEX.male:
self.change_creature( "res://scenes/creatures/human/human_male.tscn" )
if $creature:
$creature.load_from_name( p_name, p_emplacement )
func change_creature( new_model_path ):
if $creature:
var old_model = $creature
self.remove_child( old_model )
old_model.queue_free()
var new_model = load( new_model_path )
if new_model:
new_model = new_model.instance()
new_model.name = "creature"
self.add_child( new_model )
new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
new_model.duplicate_meshes()
func set_blend_shape( p_blend_shape_name, p_value ):
$creature.set_blend_shape( p_blend_shape_name, p_value )
func _on_ground_area_body_entered(body):
if not body == self:
self.ground_contacts += 1
if self.ground_contacts > 0:
# self.is_falling = false
self.is_on_ground = true
func _on_ground_area_body_exited(body):
if not body == self:
self.ground_contacts -= 1
if self.ground_contacts <= 0:
self.is_falling = true
self.is_on_ground = false
func _on_creature_animation_finished(anim_name):
if anim_name == "jump_start":
self.is_jump_started = false
self.is_jumping = true
elif anim_name == "jump_end":
self.is_falling = false
elif anim_name == "turn_right":
self.can_turn = false
elif anim_name == "turn_left":
self.can_turn = false
elif anim_name == "1h_pistol_ready_start":
self.is_readying_weapon = false
self.is_weapon_ready = true
elif anim_name == "dying":
self.is_dying = false
self.is_dead = true
func set_focus( p_focus = true ):
if p_focus:
$focus.show()
if self.player_relation == PLAYER_RELATION.neutre:
$focus.get_surface_material( 0 ).albedo_color = Color.white
elif self.player_relation == PLAYER_RELATION.friend:
$focus.get_surface_material( 0 ).albedo_color = Color.green
elif self.player_relation == PLAYER_RELATION.ennemy:
$focus.get_surface_material( 0 ).albedo_color = Color.red
else:
$focus.hide()
func get_weapons():
var weapons = []
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item )
if not weapons.size() > 0:
if Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item )
if Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item )
return weapons
func get_main_weapon_node():
var weapon = null
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
if $creature/body_parts/body/skeleton/attachment_hand_L/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
return weapon
func attack():
if self.can_attack:
var weapon = null
var attachment = null
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].attachment
if weapon:
print( "pan " + str(weapon.get_data( "damage" )) )
var weapon_node = $creature/body_parts/body/skeleton.get_node( attachment )
if weapon_node:
weapon_node = weapon_node.get_node( "handle" ).get_children()[0]
# if weapon_node is preload( "res://scenes/items/equipments/weapons/firearm.gd" ):
# weapon_node.fire( self, [self] )
#
self.can_attack = false
$attack_delay.start()
func hit( p_damage, p_from = null ):
$creature.creature.set_data( "current_life", $creature.creature.get_data( "current_life" )-p_damage )
$head_infos_viewport/head_infos/bars/life.max_value = $creature.creature.get_max_life()
$head_infos_viewport/head_infos/bars/life.value = $creature.creature.get_data( "current_life", 0 )
func die():
self.is_dying = true
func _on_creature_equip(p_slot, p_item):
var weapons = self.get_weapons()
if weapons.size() > 0:
var max_delay = null
for weapon in weapons:
if not max_delay:
max_delay = weapon.get_data( "attack_delay" )
else:
max_delay = max( max_delay, weapon.get_data( "attack_delay" ) )
$attack_delay.wait_time = max_delay
emit_signal( "equip", p_slot, p_item )
func _on_creature_unequip(p_slot):
emit_signal( "unequip", p_slot )
func _on_attack_delay_timeout():
self.can_attack = true
func _on_creature_is_dead():
self.die()

View file

@ -0,0 +1,74 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://scenes/interfaces/focus_reticle.tscn" type="PackedScene" id=1]
[ext_resource path="res://scenes/characters/head_infos.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/creatures/arche/arche.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/interfaces/focus_reticle.png" type="Texture" id=4]
[ext_resource path="res://assets/creatures/arche/area_arche.gd" type="Script" id=5]
[sub_resource type="QuadMesh" id=1]
size = Vector2( 0.5, 0.5 )
[sub_resource type="ViewportTexture" id=2]
viewport_path = NodePath("head_infos_viewport")
[sub_resource type="SpatialMaterial" id=3]
resource_local_to_scene = true
flags_transparent = true
flags_unshaded = true
params_cull_mode = 2
params_billboard_mode = 1
albedo_texture = SubResource( 2 )
[sub_resource type="CylinderShape" id=4]
height = 0.03
[sub_resource type="QuadMesh" id=5]
resource_local_to_scene = true
size = Vector2( 2, 2 )
[sub_resource type="SpatialMaterial" id=6]
resource_local_to_scene = true
render_priority = 10
flags_unshaded = true
flags_no_depth_test = true
params_billboard_mode = 1
params_use_alpha_scissor = true
params_alpha_scissor_threshold = 0.1
albedo_texture = ExtResource( 4 )
[node name="character" type="Spatial"]
script = ExtResource( 5 )
[node name="head_infos_viewport" type="Viewport" parent="."]
size = Vector2( 512, 2565 )
transparent_bg = true
[node name="head_infos" parent="head_infos_viewport" instance=ExtResource( 2 )]
[node name="head_infos_frame" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7504, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
[node name="creature" parent="." instance=ExtResource( 3 )]
[node name="look_at" type="Spatial" parent="."]
transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 1.71448, 0 )
[node name="ground_area" type="Area" parent="."]
[node name="collision_shape" type="CollisionShape" parent="ground_area"]
shape = SubResource( 4 )
[node name="focus" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
mesh = SubResource( 5 )
material/0 = SubResource( 6 )
size = Vector2( 2, 2 )
[node name="attack_delay" type="Timer" parent="."]
one_shot = true
[connection signal="body_entered" from="ground_area" to="." method="_on_ground_area_body_entered"]
[connection signal="body_exited" from="ground_area" to="." method="_on_ground_area_body_exited"]
[connection signal="timeout" from="attack_delay" to="." method="_on_attack_delay_timeout"]

View file

@ -0,0 +1,298 @@
extends KinematicBody
signal equip( p_slot, p_item )
signal unequip( p_slot )
var character = null
var rotation_speed_factor = 0.1
var move_speed = 2.5
var run_speed = 5.0
var max_speed = 12.0
export var gravity = -9.0
var velocity: = Vector3.ZERO
var is_running = false
var can_turn = false
var ground_contacts = 0
var is_jump_started = false
var is_jumping = false
var jump_strength = 250.0
var is_falling = false
var is_on_ground = true
var is_readying_weapon = false
var is_weapon_ready = false
var can_attack = true
var is_dying = false
var is_dead = false
var direction = Vector3.ZERO
var orientation = 0.0
enum PLAYER_RELATION {
neutre,
friend,
ennemy
}
export( PLAYER_RELATION ) var player_relation = PLAYER_RELATION.neutre
export( String ) var creature_filename = null setget set_creature_filename
func set_creature_filename( p_filename ):
creature_filename = p_filename
self.load_from_name( p_filename )
func _process( delta ):
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = $look_at.global_transform.basis.z * direction.z
var right: Vector3 = $look_at.global_transform.basis.x * direction.x
if forwards:
right = Vector3.ZERO
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# Rotation.
#if (self.has_node( "creature" ) and $creature.can_turn()) or self.is_readying_weapon or self.is_weapon_ready:
self.rotate_y( rotation_speed_factor * orientation )
# Movement.
velocity = self.calculate_velocity(velocity, move_direction, delta)
if not self.is_readying_weapon and not self.is_weapon_ready:
if not self.is_jumping and not self.is_jump_started and not self.is_falling:
velocity = self.move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true)
else:
velocity = self.move_and_slide(velocity, Vector3.UP, true)
# Animation.
if self.has_node( "creature" ):
# if self.is_dead:
# $creature.play( "dead_loop" )
# elif self.is_dying:
# $creature.play( "dying", 2.0 )
# elif self.is_readying_weapon:
# $creature.play( "1h_pistol_ready_start" )
# elif self.is_weapon_ready:
# $creature.play( "1h_pistol_ready_loop" )
# elif direction and not self.is_jump_started and not self.is_jumping and not self.is_falling:
# if direction.z < 0.0:
# if self.is_running:
# $creature.play( "run" , 2.0 )
# else:
# $creature.play( "walk" )
# elif direction.z > 0.0:
# if self.is_running:
# $creature.play_backwards( "run", 2.0 )
# else:
# $creature.play_backwards( "walk" )
# elif direction.x > 0.0:
# $creature.play( "strafe_right" )
# elif direction.x < 0.0:
# $creature.play( "strafe_left" )
# elif self.is_jump_started and not self.is_jumping:
# $creature.play( "jump_start" )
# elif self.is_jumping or self.is_falling:
# if not self.is_on_ground:
# $creature.play( "jump_loop" )
# else:
# $creature.play( "jump_end", 2 )
# elif not self.orientation == 0.0:
# if self.orientation < 0.0:
# $creature.play( "turn_right", 2.0 )
# elif self.orientation > 0.0:
# $creature.play( "turn_left", 2.0 )
# else:
# $creature.play( "idle" )
$creature.play( "idle" )
func calculate_velocity(
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
# var velocity_new := move_direction
var velocity_new = Vector3.ZERO
if not self.is_jump_started:
velocity_new = move_direction
if self.is_running:
velocity_new *= run_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
if self.is_jumping:
velocity_new.y += self.jump_strength * delta
self.is_jumping = false
self.is_falling = true
if self.is_falling:
velocity_new.x *= 2.0
velocity_new.z *= 2.0
return velocity_new
func load_from_name( p_name, p_emplacement = null ):
var creature = Datas.Creature.new()
creature.set_data( "name", p_name )
creature.load( null, p_emplacement )
# if creature.get_data( "race" ) == Globals.RACE.human:
# if creature.get_data( "sex" ) == Globals.SEX.female:
# self.change_creature( "res://scenes/creatures/human/human_female.tscn" )
# elif creature.get_data( "sex" ) == Globals.SEX.male:
# self.change_creature( "res://scenes/creatures/human/human_male.tscn" )
if $creature:
$creature.load_from_name( p_name, p_emplacement )
func change_creature( new_model_path ):
if $creature:
var old_model = $creature
self.remove_child( old_model )
old_model.queue_free()
var new_model = load( new_model_path )
if new_model:
new_model = new_model.instance()
new_model.name = "creature"
self.add_child( new_model )
new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
new_model.duplicate_meshes()
func set_blend_shape( p_blend_shape_name, p_value ):
$creature.set_blend_shape( p_blend_shape_name, p_value )
func _on_ground_area_body_entered(body):
if not body == self:
self.ground_contacts += 1
if self.ground_contacts > 0:
# self.is_falling = false
self.is_on_ground = true
func _on_ground_area_body_exited(body):
if not body == self:
self.ground_contacts -= 1
if self.ground_contacts <= 0:
self.is_falling = true
self.is_on_ground = false
func _on_creature_animation_finished(anim_name):
if anim_name == "jump_start":
self.is_jump_started = false
self.is_jumping = true
elif anim_name == "jump_end":
self.is_falling = false
elif anim_name == "turn_right":
self.can_turn = false
elif anim_name == "turn_left":
self.can_turn = false
elif anim_name == "1h_pistol_ready_start":
self.is_readying_weapon = false
self.is_weapon_ready = true
elif anim_name == "dying":
self.is_dying = false
self.is_dead = true
func set_focus( p_focus = true ):
if p_focus:
$focus.show()
if self.player_relation == PLAYER_RELATION.neutre:
$focus.get_surface_material( 0 ).albedo_color = Color.white
elif self.player_relation == PLAYER_RELATION.friend:
$focus.get_surface_material( 0 ).albedo_color = Color.green
elif self.player_relation == PLAYER_RELATION.ennemy:
$focus.get_surface_material( 0 ).albedo_color = Color.red
else:
$focus.hide()
func get_weapons():
var weapons = []
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item )
if not weapons.size() > 0:
if Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item )
if Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item )
return weapons
func get_main_weapon_node():
var weapon = null
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
if $creature/body_parts/body/skeleton/attachment_hand_L/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
return weapon
func attack():
if self.can_attack:
var weapon = null
var attachment = null
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].attachment
if weapon:
print( "pan " + str(weapon.get_data( "damage" )) )
var weapon_node = $creature/body_parts/body/skeleton.get_node( attachment )
if weapon_node:
weapon_node = weapon_node.get_node( "handle" ).get_children()[0]
# if weapon_node is preload( "res://scenes/items/equipments/weapons/firearm.gd" ):
# weapon_node.fire( self, [self] )
#
self.can_attack = false
$attack_delay.start()
func hit( p_damage, p_from = null ):
$creature.creature.set_data( "current_life", $creature.creature.get_data( "current_life" )-p_damage )
$head_infos_viewport/head_infos/bars/life.max_value = $creature.creature.get_max_life()
$head_infos_viewport/head_infos/bars/life.value = $creature.creature.get_data( "current_life", 0 )
func die():
self.is_dying = true
func _on_creature_equip(p_slot, p_item):
var weapons = self.get_weapons()
if weapons.size() > 0:
var max_delay = null
for weapon in weapons:
if not max_delay:
max_delay = weapon.get_data( "attack_delay" )
else:
max_delay = max( max_delay, weapon.get_data( "attack_delay" ) )
$attack_delay.wait_time = max_delay
emit_signal( "equip", p_slot, p_item )
func _on_creature_unequip(p_slot):
emit_signal( "unequip", p_slot )
func _on_attack_delay_timeout():
self.can_attack = true
func _on_creature_is_dead():
self.die()

View file

@ -0,0 +1,76 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://scenes/characters/head_infos.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/creatures/arche/skin_arche.tscn" type="PackedScene" id=2]
[ext_resource path="res://scenes/interfaces/focus_reticle.tscn" type="PackedScene" id=3]
[ext_resource path="res://assets/interfaces/focus_reticle.png" type="Texture" id=4]
[sub_resource type="QuadMesh" id=1]
size = Vector2( 0.5, 0.5 )
[sub_resource type="ViewportTexture" id=2]
viewport_path = NodePath("head_infos_viewport")
[sub_resource type="SpatialMaterial" id=3]
resource_local_to_scene = true
flags_transparent = true
flags_unshaded = true
albedo_texture = SubResource( 2 )
[sub_resource type="CylinderShape" id=4]
resource_local_to_scene = true
[sub_resource type="CylinderShape" id=5]
resource_local_to_scene = true
height = 0.03
[sub_resource type="QuadMesh" id=6]
resource_local_to_scene = true
size = Vector2( 2.1, 1.8 )
[sub_resource type="SpatialMaterial" id=7]
resource_local_to_scene = true
render_priority = 10
flags_unshaded = true
flags_no_depth_test = true
params_billboard_mode = 1
params_use_alpha_scissor = true
params_alpha_scissor_threshold = 0.1
albedo_texture = ExtResource( 4 )
[node name="kinematic_body" type="KinematicBody"]
[node name="head_infos_viewport" type="Viewport" parent="."]
size = Vector2( 512, 2565 )
transparent_bg = true
[node name="head_infos" parent="head_infos_viewport" instance=ExtResource( 1 )]
[node name="head_infos_frame" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.96237, 0 )
visible = false
mesh = SubResource( 1 )
material/0 = SubResource( 3 )
[node name="creature" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
shape = SubResource( 4 )
[node name="look_at" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.86429, 0 )
[node name="ground_area" type="Area" parent="."]
[node name="collision_shape" type="CollisionShape" parent="ground_area"]
shape = SubResource( 5 )
[node name="focus" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0 )
visible = false
mesh = SubResource( 6 )
material/0 = SubResource( 7 )
size = Vector2( 2.1, 1.8 )
[node name="attack_delay" type="Timer" parent="."]
one_shot = true
[connection signal="timeout" from="attack_delay" to="focus" method="_on_attack_delay_timeout"]

View file

@ -0,0 +1,65 @@
extends Spatial
onready var camera_tps = $character/spring_arm/camera_tps
onready var camera_fps = $character/spring_arm/camera_fps
var mouse_delta = Vector2.ZERO
var zoom_level = 0
var camera_position = Vector3( 0.0, 2.0, -2.0 )
var proximity_objects = []
var focused_object = null
var focus_index = 0
static func get_input_direction() -> Vector3:
return Vector3(
Input.get_action_strength("move_strafe_right") - Input.get_action_strength("move_strafe_left"),
0,
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
func _input( event ):
# Run.
if event.is_action_pressed( "move_toggle_run" ):
$character.is_running = not $character.is_running
# Camera.
if event.is_action( "camera_zoom_in" ):
self.zoom_level += 1
elif event.is_action( "camera_zoom_out" ):
self.zoom_level -= 1
if event.is_action_pressed( "camera_reset_view" ):
$character/spring_arm.rotation = Vector3.ZERO
self.zoom_level = 0
if event.is_action_pressed( "camera_switch" ):
if self.camera_tps.current:
self.camera_fps.make_current()
$character/spring_arm.rotation = Vector3.ZERO
# self.hide()
else:
self.camera_tps.make_current()
# self.show()
if event is InputEventMouseMotion:
self.mouse_delta = event.relative
# Jump.
if event.is_action_pressed( "move_jump" ) and not $character.is_falling:
$character.is_jump_started = true
if event.is_action_pressed( "interact" ):
# self.interact()
pass
if event.is_action_pressed( "focus_next" ):
# self.focus_next()
pass
func _process( delta ):
$character.direction = self.get_input_direction()
# Rotation.
if not Input.is_key_pressed( KEY_SHIFT ) and not $character.is_jump_started:
$character.orientation = (Input.get_action_strength("move_turn_left") - Input.get_action_strength("move_turn_right"))
else:
$character.orientation = 0.0
# Camera.
if not self.mouse_delta == Vector2.ZERO and self.camera_tps.current:
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
$character/spring_arm.rotate_y( -self.mouse_delta.x * 0.01 )
self.camera_tps.rotate_x( self.mouse_delta.y * 0.01 )

View file

@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://assets/creatures/arche/character_arche.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/creatures/arche/player_arche.gd" type="Script" id=2]
[ext_resource path="res://assets/creatures/arche/character_arche.gd" type="Script" id=3]
[node name="spatial" type="Spatial"]
script = ExtResource( 2 )
[node name="character" parent="." instance=ExtResource( 1 )]
script = ExtResource( 3 )
[node name="spring_arm" type="Spatial" parent="character"]
[node name="camera_tps" type="Camera" parent="character/spring_arm"]
transform = Transform( 1, 0, 0, 0, 0.944077, 0.329724, 0, -0.329724, 0.944077, 0, 2.4017, 2.25811 )
current = true
near = 0.01
far = 100000.0
[node name="camera_fps" type="Camera" parent="character/spring_arm"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.90314, 0 )
near = 0.01
far = 100000.0

View file

@ -0,0 +1,411 @@
extends CollisionShape
signal animation_finished( anim_name )
signal equip( p_slot, p_item )
signal unequip( p_slot )
signal is_dead
var creature = Datas.Human.new()
var eye_color_list = [ "blue_eye", "bluegreen_eye","brown_eye","deepblue_eye","green_eye","grey_eye","ice_eye","lightblue_eye" ]
class Slot:
var item = null
var attachment = null
func _init( p_attachment = null ):
self.attachment = p_attachment
var slots = { Datas.Equipment.SLOT.cloth_hand: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_face: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_head: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_torso: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_legs: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_feet: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_back: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.weapon_hand_right: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hand_left: Slot.new( "attachment_hand_L" )\
, Datas.Equipment.SLOT.weapon_hands: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hip_right: Slot.new( "attachment_hips_R" )\
, Datas.Equipment.SLOT.weapon_hip_left: Slot.new( "attachment_hips_L" )\
, Datas.Equipment.SLOT.weapon_back_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_back_left: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_left: Slot.new() }
func _ready():
self.duplicate_meshes()
func duplicate_meshes():
# for body in $body_parts.get_children():
# for mesh in body.get_node( "skeleton" ).get_children():
# if mesh is MeshInstance:
# var new_mat = mesh.get( "material/0" ).duplicate()
# var new_mesh = mesh.mesh.duplicate()
# mesh.mesh = new_mesh
# mesh.set( "material/0", new_mat )
# for body in $hair_parts.get_children():
# for mesh in body.get_node( "skeleton" ).get_children():
# if mesh is MeshInstance:
# var new_mat = mesh.get( "material/0" ).duplicate()
# var new_mesh = mesh.mesh.duplicate()
# mesh.mesh = new_mesh
# mesh.set( "material/0", new_mat )
# for body in $cloths.get_children():
# for mesh in body.get_node( "skeleton" ).get_children():
# if mesh is MeshInstance:
# var new_mat = mesh.get( "material/0" ).duplicate()
# var new_mesh = mesh.mesh.duplicate()
# mesh.mesh = new_mesh
# mesh.set( "material/0", new_mat )
self.update()
func set_blend_shape( p_blend_shape_name, p_value ):
# for child in $body_parts.get_children():
# var skeleton = child.get_node( "skeleton" )
# for node in skeleton.get_children():
# if node is MeshInstance:
# node.set( "blend_shapes/"+p_blend_shape_name, p_value )
# for child in $hair_parts.get_children():
# var skeleton = child.get_node( "skeleton" )
# for node in skeleton.get_children():
# if node is MeshInstance:
# node.set( "blend_shapes/"+p_blend_shape_name, p_value )
# for child in $cloths.get_children():
# var skeleton = child.get_node( "skeleton" )
# for node in skeleton.get_children():
# if node is MeshInstance:
# node.set( "blend_shapes/"+p_blend_shape_name, p_value )
pass
func load_from_name( p_name, p_emplacement = "usr" ):
var new_creature = Datas.Human.new()
var name_split = p_name.split( "_" )
new_creature.set_data( "first_name", name_split[0] )
new_creature.set_data( "last_name", name_split[1] )
new_creature.load( null, p_emplacement )
self.creature = new_creature
self.update()
func update():
# if self.creature:
# self.scale = Vector3( self.creature.get_data( "size" ), self.creature.get_data( "size" ), self.creature.get_data( "size" ) )
#
# self.set_blend_shape( "caucasian", self.creature.get_data( "caucasian" ) )
# self.set_blend_shape( "african", self.creature.get_data( "african" ) )
# self.set_blend_shape( "asian", self.creature.get_data( "asian" ) )
#
# if self.creature.get_data( "sex" ) == Globals.SEX.female:
# if self.creature.get_data( "skin" ) == 0:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse.png" ) )
# elif self.creature.get_data( "skin" ) == 1:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse3.png" ) )
# elif self.creature.get_data( "skin" ) == 2:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_female_diffuse.png" ) )
# elif self.creature.get_data( "sex" ) == Globals.SEX.male:
# if self.creature.get_data( "skin" ) == 0:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse2.png" ) )
# elif self.creature.get_data( "skin" ) == 1:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse3.png" ) )
# elif self.creature.get_data( "skin" ) == 2:
# self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_male_diffuse.png" ) )
#
# if self.creature.get_data( "sex" ) == Globals.SEX.female:
# if self.creature.get_data( "hair" ) == 0:
# self.get_node( "hair_parts/mh_human_female_hair" ).hide()
# elif self.creature.get_data( "hair" ) == 1:
# self.get_node( "hair_parts/mh_human_female_hair" ).show()
# self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_001.png" )
# elif self.creature.get_data( "hair" ) == 2:
# self.get_node( "hair_parts/mh_human_female_hair" ).show()
# self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_002.png" )
# elif self.creature.get_data( "sex" ) == Globals.SEX.male:
# if self.creature.get_data( "hair" ) == 0:
# self.get_node( "hair_parts/mh_human_male_hair" ).hide()
# elif self.creature.get_data( "hair" ) == 1:
# self.get_node( "hair_parts/mh_human_male_hair" ).show()
# self.get_node( "hair_parts/mh_human_male_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_male_hair.png" )
#
#
# for hair in $hair_parts.get_children():
# if hair.has_node( "skeleton/hair" ) and hair.get_node( "skeleton/hair" ).get_surface_material( 0 ):
# hair.get_node( "skeleton/hair" ).get_surface_material( 0 ).albedo_color = self.creature.get_data( "hair_color" )
#
#
# if self.creature.get_data( "muscles" ) > 0.0:
# self.set_blend_shape( "muscles_min", 0.0 )
# self.set_blend_shape( "muscles_max", self.creature.get_data( "muscles" ) )
# elif self.creature.get_data( "muscles" ) < 0.0:
# self.set_blend_shape( "muscles_min", -self.creature.get_data( "muscles" ) )
# self.set_blend_shape( "muscles_max", 0.0 )
# else:
# self.set_blend_shape( "muscles_min", 0.0 )
# self.set_blend_shape( "muscles_max", 0.0 )
#
# if self.creature.get_data( "fat" ) > 0.0:
# self.set_blend_shape( "fat_min", 0.0 )
# self.set_blend_shape( "fat_max", self.creature.get_data( "fat" ) )
# elif self.creature.get_data( "fat" ) < 0.0:
# self.set_blend_shape( "fat_min", -self.creature.get_data( "fat" ) )
# self.set_blend_shape( "fat_max", 0.0 )
# else:
# self.set_blend_shape( "fat_min", 0.0 )
# self.set_blend_shape( "fat_max", 0.0 )
#
# if self.creature.get_data( "proportion" ) > 0.0:
# self.set_blend_shape( "proportion_min", 0.0 )
# self.set_blend_shape( "proportion_max", self.creature.get_data( "proportion" ) )
# elif self.creature.get_data( "proportion" ) < 0.0:
# self.set_blend_shape( "proportion_min", -self.creature.get_data( "proportion" ) )
# self.set_blend_shape( "proportion_max", 0.0 )
# else:
# self.set_blend_shape( "proportion_min", 0.0 )
# self.set_blend_shape( "proportion_max", 0.0 )
#
# if self.creature.get_data( "breast" ) > 0.0:
# self.set_blend_shape( "breast_min", 0.0 )
# self.set_blend_shape( "breast_max", self.creature.get_data( "breast" ) )
# elif self.creature.get_data( "breast" ) < 0.0:
# self.set_blend_shape( "breast_min", -self.creature.get_data( "breast" ) )
# self.set_blend_shape( "breast_max", 0.0 )
# else:
# self.set_blend_shape( "breast_min", 0.0 )
# self.set_blend_shape( "breast_max", 0.0 )
#
# if self.creature.get_data( "sex" ) == Globals.SEX.female:
# self.set_blend_shape( "pregnancy", self.creature.get_data( "pregnancy" ) )
#
# # Skin tone.
# if self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) and self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) is ShaderMaterial:
# var color = self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).get_shader_param( "albedo" )
# color.v = 1.0 - self.creature.get_data( "skin_tone" )
# self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).set_shader_param( "albedo", color )
#
# self.set_blend_shape( "cleft_chin", self.creature.get_data( "cleft_chin" ) )
# self.set_blend_shape( "chin_angle", self.creature.get_data( "chin_angle" ) )
#
# if self.creature.get_data( "mouth_horiz" ) > 0.0:
# self.set_blend_shape( "mouth_horiz_min", 0.0 )
# self.set_blend_shape( "mouth_horiz_max", self.creature.get_data( "mouth_horiz" ) )
# elif self.creature.get_data( "mouth_horiz" ) < 0.0:
# self.set_blend_shape( "mouth_horiz_min", -self.creature.get_data( "mouth_horiz" ) )
# self.set_blend_shape( "mouth_horiz_max", 0.0 )
# else:
# self.set_blend_shape( "mouth_horiz_min", 0.0 )
# self.set_blend_shape( "mouth_horiz_max", 0.0 )
#
# if self.creature.get_data( "mouth_vert" ) > 0.0:
# self.set_blend_shape( "mouth_vert_min", 0.0 )
# self.set_blend_shape( "mouth_vert_max", self.creature.get_data( "mouth_vert" ) )
# elif self.creature.get_data( "mouth_vert" ) < 0.0:
# self.set_blend_shape( "mouth_vert_min", -self.creature.get_data( "mouth_vert" ) )
# self.set_blend_shape( "mouth_vert_max", 0.0 )
# else:
# self.set_blend_shape( "mouth_vert_min", 0.0 )
# self.set_blend_shape( "mouth_vert_max", 0.0 )
#
# if self.creature.get_data( "nose_galbe" ) > 0.0:
# self.set_blend_shape( "nose_galbe_min", 0.0 )
# self.set_blend_shape( "nose_galbe_max", self.creature.get_data( "nose_galbe" ) )
# elif self.creature.get_data( "nose_galbe" ) < 0.0:
# self.set_blend_shape( "nose_galbe_min", -self.creature.get_data( "nose_galbe" ) )
# self.set_blend_shape( "nose_galbe_max", 0.0 )
# else:
# self.set_blend_shape( "nose_galbe_min", 0.0 )
# self.set_blend_shape( "nose_galbe_max", 0.0 )
#
# if self.creature.get_data( "nose_grec" ) > 0.0:
# self.set_blend_shape( "nose_grec_min", 0.0 )
# self.set_blend_shape( "nose_grec_max", self.creature.get_data( "nose_grec" ) )
# elif self.creature.get_data( "nose_grec" ) < 0.0:
# self.set_blend_shape( "nose_grec_min", -self.creature.get_data( "nose_grec" ) )
# self.set_blend_shape( "nose_grec_max", 0.0 )
# else:
# self.set_blend_shape( "nose_grec_min", 0.0 )
# self.set_blend_shape( "nose_grec_max", 0.0 )
#
# if self.creature.get_data( "nose_horiz" ) > 0.0:
# self.set_blend_shape( "nose_horiz_min", 0.0 )
# self.set_blend_shape( "nose_horiz_max", self.creature.get_data( "nose_horiz" ) )
# elif self.creature.get_data( "nose_horiz" ) < 0.0:
# self.set_blend_shape( "nose_horiz_min", -self.creature.get_data( "nose_horiz" ) )
# self.set_blend_shape( "nose_horiz_max", 0.0 )
# else:
# self.set_blend_shape( "nose_horiz_min", 0.0 )
# self.set_blend_shape( "nose_horiz_max", 0.0 )
#
# if self.creature.get_data( "nose_depth" ) > 0.0:
# self.set_blend_shape( "nose_depth_min", 0.0 )
# self.set_blend_shape( "nose_depth_max", self.creature.get_data( "nose_depth" ) )
# elif self.creature.get_data( "nose_depth" ) < 0.0:
# self.set_blend_shape( "nose_depth_min", -self.creature.get_data( "nose_depth" ) )
# self.set_blend_shape( "nose_depth_max", 0.0 )
# else:
# self.set_blend_shape( "nose_depth_min", 0.0 )
# self.set_blend_shape( "nose_depth_max", 0.0 )
#
#
# self.get_node( "body_parts/body/skeleton/eyes" ).get_surface_material( 0 ).albedo_texture = load( "res://assets/creatures/human/textures/"+self.eye_color_list[ self.creature.get_data( "eyes_color", 0 ) ]+".png" )
#
# if self.creature.get_data( "eyes_vert" ) > 0.0:
# self.set_blend_shape( "eyes_vert_min", 0.0 )
# self.set_blend_shape( "eyes_vert_max", self.creature.get_data( "eyes_vert" ) )
# elif self.creature.get_data( "eyes_vert" ) < 0.0:
# self.set_blend_shape( "eyes_vert_min", -self.creature.get_data( "eyes_vert" ) )
# self.set_blend_shape( "eyes_vert_max", 0.0 )
# else:
# self.set_blend_shape( "eyes_vert_min", 0.0 )
# self.set_blend_shape( "eyes_vert_max", 0.0 )
#
# if self.creature.get_data( "eyes_gap" ) > 0.0:
# self.set_blend_shape( "eyes_gap_min", 0.0 )
# self.set_blend_shape( "eyes_gap_max", self.creature.get_data( "eyes_gap" ) )
# elif self.creature.get_data( "eyes_gap" ) < 0.0:
# self.set_blend_shape( "eyes_gap_min", -self.creature.get_data( "eyes_gap" ) )
# self.set_blend_shape( "eyes_gap_max", 0.0 )
# else:
# self.set_blend_shape( "eyes_gap_min", 0.0 )
# self.set_blend_shape( "eyes_gap_max", 0.0 )
#
# self.set_blend_shape( "earlobes", self.creature.get_data( "earlobes" ) )
# self.set_blend_shape( "ears_wing", self.creature.get_data( "ears_wing" ) )
#
# if self.creature.get_data( "lips_up_shape" ) > 0.0:
# self.set_blend_shape( "lips_up_shape_min", 0.0 )
# self.set_blend_shape( "lips_up_shape_max", self.creature.get_data( "lips_up_shape" ) )
# elif self.creature.get_data( "lips_up_shape" ) < 0.0:
# self.set_blend_shape( "lips_up_shape_min", -self.creature.get_data( "lips_up_shape" ) )
# self.set_blend_shape( "lips_up_shape_max", 0.0 )
# else:
# self.set_blend_shape( "lips_up_shape_min", 0.0 )
# self.set_blend_shape( "lips_up_shape_max", 0.0 )
#
# if self.creature.get_data( "lips_up_shape_2" ) > 0.0:
# self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
# self.set_blend_shape( "lips_up_shape_2_max", self.creature.get_data( "lips_up_shape_2" ) )
# elif self.creature.get_data( "lips_up_shape_2" ) < 0.0:
# self.set_blend_shape( "lips_up_shape_2_min", -self.creature.get_data( "lips_up_shape_2" ) )
# self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
# else:
# self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
# self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
#
# self.set_blend_shape( "nipple_flat", 1.0 )
pass
func play( anim_name, speed = 1.0 ):
for child in $body_parts.get_children():
child.get_node( "AnimationPlayer" ).playback_speed = speed
if child.get_node( "AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "AnimationPlayer" ).play( anim_name )
func play_backwards( anim_name, speed = 1.0 ):
for child in $body_parts.get_children():
child.get_node( "AnimationPlayer" ).playback_speed = speed
if child.get_node( "AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "AnimationPlayer" ).play_backwards( anim_name )
# for child in $hair_parts.get_children():
# child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
# if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
# child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
# for child in $cloths.get_children():
# child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
# if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
# child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
func can_turn():
# var animation_player = $body_parts/body/skeleton/AnimationPlayer
# return (animation_player.current_animation.begins_with( "turn_") and animation_player.current_animation_position >= 1.2) or (not animation_player.current_animation.begins_with( "turn_") and not animation_player.current_animation.begins_with( "idle"))
return true
func equip( p_item, p_slot = null ):
# var model = load( p_item.get_data( "model_equiped", "") )
# if not model:
# model = load( p_item.get_data( "model", "") )
# if model:
# model = model.instance()
# var attachment = null
# if not p_slot:
# p_slot = p_item.get_data( "default_slot" )
# if p_slot and int(p_slot) in self.slots:
# self.unequip( p_slot )
# attachment = self.slots[ int(p_slot) ].attachment
# self.slots[ int(p_slot) ].item = p_item
# if attachment:
# if attachment == "cloths":
# model.name = str(int(p_slot))
# $cloths.add_child( model )
# var animation = $body_parts/body/skeleton/AnimationPlayer.current_animation
# var animation_position = $body_parts/body/skeleton/AnimationPlayer.current_animation_position
# var animation_speed = $body_parts/body/skeleton/AnimationPlayer.playback_speed
# model.get_node( "skeleton/AnimationPlayer" ).stop()
# model.get_node( "skeleton/AnimationPlayer" ).set( "playback_speed", animation_speed )
# model.get_node( "skeleton/AnimationPlayer" ).play( animation )
# model.get_node( "skeleton/AnimationPlayer" ).advance( animation_position )
# else:
# if $body_parts/body/skeleton.has_node( attachment ):
# $body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).add_child( model )
#
# emit_signal( "equip", int(p_slot), p_item )
pass
func unequip( p_slot ):
# if p_slot and int(p_slot) in self.slots:
# if self.slots[ int(p_slot) ].item:
# var attachment = self.slots[ int(p_slot) ].attachment
# self.slots[ int(p_slot) ].item = null
# if attachment:
# if attachment == "cloths":
# var node = $cloths.get_node( str(p_slot) )
# if node:
# $cloths.remove_child( node )
# node.queue_free()
# else:
# for child in $body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).get_children():
# $body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).remove_child( child )
# child.queue_free()
# emit_signal( "unequip", int(p_slot) )
pass
func drop_item( p_item ):
# var new_inventory = self.creature.get_data( "inventory" )
# var item_index = new_inventory.find( p_item )
# if item_index != -1:
# if new_inventory[ item_index ].get_data( "dropable", true ):
# new_inventory[ item_index ].set_data( "number", new_inventory[ item_index ].get_data( "number" )-1 )
#
# if new_inventory[ item_index ].get_data( "number" ) <= 0:
# new_inventory.remove( item_index )
#
# var pickup_item_node = preload( "res://scenes/items/pickup_item.tscn" ).instance()
# pickup_item_node.item_filename = p_item.get_filename()
# pickup_item_node.global_transform = $drop_point.global_transform
#
# var pickup_item = Datas.PickupItem.new( p_item.get_filename(), $drop_point.global_transform, p_item )
# pickup_item_node.item = pickup_item
#
# if self.get_tree().get_root().has_node( "main/scene/game" ):
# self.get_tree().get_root().get_node( "main/scene/game" ).get_node( "pickups" ).add_child( pickup_item_node )
pass
func _on_body_animation_finished( anim_name ):
emit_signal( "animation_finished", anim_name )
func _on_body_limb_body_entered(limb, body):
if body.is_in_group( "bullet" ):
if limb == Datas.Cloth.LIMB.head:
#var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
#$body_parts/body/skeleton/limb_head.add_child( blood_particle )
#blood_particle.emit()
#emit_signal( "is_dead" )
#self.creature.set_data( "current_life", 0.0 )
pass
else:
#var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
#$body_parts/body/skeleton/limb_torso_1.add_child( blood_particle )
#blood_particle.emit()
pass

View file

@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/creatures/arche/arche.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/creatures/arche/skin_arche.gd" type="Script" id=2]
[node name="collision_shape" type="CollisionShape"]
script = ExtResource( 2 )
[node name="body_parts" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
[node name="arche" parent="body_parts" instance=ExtResource( 1 )]

Binary file not shown.

Binary file not shown.

Binary file not shown.