From 8152886f5df7ddedf6796e4246ea12e8d1fa61ba Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 16 Jul 2020 23:33:41 +0200 Subject: [PATCH] Convert 2 particle effects to 2d, and fix adding effects to skeletons. --- game/characters/SimpleCharacter.gd | 36 ++++++++++++-- game/characters/SimpleCharacter.tscn | 30 +++++++++++- .../spell_effects/nature/AOSCastFinish.tscn | 2 - .../spell_effects/nature/AmplifyPain.tscn | 31 ++++-------- .../spell_effects/nature/NatureCast.tscn | 49 +++++-------------- .../spell_effects/nature/NautreSwiftness.tscn | 3 -- game/player/CharacterSkeletonAttachPoint.gd | 11 +++-- game/project.godot | 2 +- 8 files changed, 88 insertions(+), 76 deletions(-) diff --git a/game/characters/SimpleCharacter.gd b/game/characters/SimpleCharacter.gd index 0d6386c..26b8b61 100644 --- a/game/characters/SimpleCharacter.gd +++ b/game/characters/SimpleCharacter.gd @@ -56,11 +56,37 @@ func update_facing(input_direction : Vector2) -> void: _facing = CharacterFacing.FACING_LEFT sprite.transform.x.x = 1 -func add_effect(bone_id : int, effect : PackedScene) -> void: - pass - -func remove_effect(bone_id : int, effect : PackedScene) -> void: - pass +#func add_effect(bone_id : int, effect : PackedScene) -> void: +# pass +# +#func remove_effect(bone_id : int, effect : PackedScene) -> void: +# pass +# +func _common_attach_point_index_get(point): + if point == EntityEnums.COMMON_SKELETON_POINT_LEFT_HAND: + return 0 + elif point == EntityEnums.COMMON_SKELETON_POINT_ROOT: + return 3 + elif point == EntityEnums.COMMON_SKELETON_POINT_SPINE_2: + return 6 + elif point == EntityEnums.COMMON_SKELETON_POINT_RIGHT_HAND: + return 1 + elif point == EntityEnums.COMMON_SKELETON_POINT_BACK: + return 6 + elif point == EntityEnums.COMMON_SKELETON_POINT_RIGHT_HIP: + return 4 + elif point == EntityEnums.COMMON_SKELETON_POINT_WEAPON_LEFT: + return 7 + elif point == EntityEnums.COMMON_SKELETON_POINT_WEAPON_LEFT_BACK: + return 9 + elif point == EntityEnums.COMMON_SKELETON_POINT_WEAPON_RIGHT: + return 8 + elif point == EntityEnums.COMMON_SKELETON_POINT_WEAPON_RIGHT_BACK: + return 10 + elif point == EntityEnums.COMMON_SKELETON_POINT_WEAPON_LEFT_SHIELD: + return 11 + + return 3 func get_animation_player() -> AnimationPlayer: return null diff --git a/game/characters/SimpleCharacter.tscn b/game/characters/SimpleCharacter.tscn index 7502c90..6de1dec 100644 --- a/game/characters/SimpleCharacter.tscn +++ b/game/characters/SimpleCharacter.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://characters/SimpleCharacter.gd" type="Script" id=1] +[ext_resource path="res://player/CharacterSkeletonAttachPoint.gd" type="Script" id=2] [node name="Character" type="CharacterSkeleton2D"] entity_type = 1 @@ -19,19 +20,46 @@ attach_point_paths/11_weapon_shield_left = NodePath("WeaponLeft") script = ExtResource( 1 ) [node name="LeftHand" type="Node2D" parent="."] +position = Vector2( 5.95948, 5.29732 ) +z_index = 1 +script = ExtResource( 2 ) [node name="RightHand" type="Node2D" parent="."] +position = Vector2( -6.0257, 5.2311 ) +z_index = 1 +script = ExtResource( 2 ) [node name="Torso" type="Node2D" parent="."] +position = Vector2( 0.0662193, 1.39054 ) +z_index = 1 +script = ExtResource( 2 ) [node name="Root" type="Node2D" parent="."] +position = Vector2( -0.0662155, 14.369 ) +z_index = 1 +script = ExtResource( 2 ) [node name="RightHip" type="Node2D" parent="."] +position = Vector2( -2.45001, 3.77434 ) +z_index = 1 +script = ExtResource( 2 ) [node name="LeftHip" type="Node2D" parent="."] +position = Vector2( 2.45001, 4.0392 ) +z_index = 1 +script = ExtResource( 2 ) [node name="Spine2" type="Node2D" parent="."] +position = Vector2( -0.132435, -1.98649 ) +z_index = 1 +script = ExtResource( 2 ) [node name="WeaponLeft" type="Node2D" parent="."] +position = Vector2( 6.09191, 5.2311 ) +z_index = 1 +script = ExtResource( 2 ) [node name="WeaponRight" type="Node2D" parent="."] +position = Vector2( -6.0257, 5.16488 ) +z_index = 1 +script = ExtResource( 2 ) diff --git a/game/modules/entity_classes/naturalist/spell_effects/nature/AOSCastFinish.tscn b/game/modules/entity_classes/naturalist/spell_effects/nature/AOSCastFinish.tscn index 8185342..5e2e23c 100644 --- a/game/modules/entity_classes/naturalist/spell_effects/nature/AOSCastFinish.tscn +++ b/game/modules/entity_classes/naturalist/spell_effects/nature/AOSCastFinish.tscn @@ -3,8 +3,6 @@ [ext_resource path="res://modules/core/shaders/2_simple_particle_billboard_shader.shader" type="Shader" id=1] [ext_resource path="res://modules/entity_classes/naturalist/spell_effects/textures/small_star.png" type="Texture" id=2] - - [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 1 ) shader_param/albedo = Color( 1, 1, 1, 1 ) diff --git a/game/modules/entity_classes/naturalist/spell_effects/nature/AmplifyPain.tscn b/game/modules/entity_classes/naturalist/spell_effects/nature/AmplifyPain.tscn index b094d27..8060c8c 100644 --- a/game/modules/entity_classes/naturalist/spell_effects/nature/AmplifyPain.tscn +++ b/game/modules/entity_classes/naturalist/spell_effects/nature/AmplifyPain.tscn @@ -1,41 +1,30 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://modules/core/shaders/2_simple_particle_billboard_shader.shader" type="Shader" id=1] [ext_resource path="res://modules/entity_classes/naturalist/spell_effects/textures/star.png" type="Texture" id=2] - - -[sub_resource type="ShaderMaterial" id=1] -shader = ExtResource( 1 ) -shader_param/albedo = Color( 0.0627451, 0.741176, 0.619608, 1 ) -shader_param/texture_albedo = ExtResource( 2 ) - -[sub_resource type="QuadMesh" id=2] -material = SubResource( 1 ) - [sub_resource type="Animation" id=3] resource_name = "Anim" length = 0.3 step = 0.01 tracks/0/type = "value" -tracks/0/path = NodePath("MeshInstance:scale") +tracks/0/path = NodePath("Sprite:scale") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 0.08, 0.09, 0.3 ), -"transitions": PoolRealArray( 5.09824, 1, 1.31951, 1 ), +"times": PoolRealArray( 0, 0.11, 0.3 ), +"transitions": PoolRealArray( 5.09823, 1.36604, 1 ), "update": 0, -"values": [ Vector3( 0.1, 0.1, 0.1 ), Vector3( 1, 1, 1 ), Vector3( 1, 1, 1 ), Vector3( 0.1, 0.1, 0.1 ) ] +"values": [ Vector2( 0.1, 0.1 ), Vector2( 1, 1 ), Vector2( 0.1, 0.1 ) ] } -[node name="AmplifyPain" type="Spatial"] +[node name="AmplifyPain" type="Node2D"] -[node name="MeshInstance" type="MeshInstance" parent="."] -transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0 ) -mesh = SubResource( 2 ) -material/0 = null +[node name="Sprite" type="Sprite" parent="."] +modulate = Color( 0.0627451, 0.741176, 0.619608, 1 ) +scale = Vector2( 0.1, 0.1 ) +texture = ExtResource( 2 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] autoplay = "Anim" diff --git a/game/modules/entity_classes/naturalist/spell_effects/nature/NatureCast.tscn b/game/modules/entity_classes/naturalist/spell_effects/nature/NatureCast.tscn index 9bd91e0..5ad8067 100644 --- a/game/modules/entity_classes/naturalist/spell_effects/nature/NatureCast.tscn +++ b/game/modules/entity_classes/naturalist/spell_effects/nature/NatureCast.tscn @@ -1,60 +1,33 @@ -[gd_scene load_steps=9 format=2] +[gd_scene load_steps=3 format=2] -[ext_resource path="res://modules/core/shaders/3_simple_y_billboard.shader" type="Shader" id=1] -[ext_resource path="res://modules/core/shaders/2_simple_particle_billboard_shader.shader" type="Shader" id=2] [ext_resource path="res://modules/entity_classes/naturalist/spell_effects/textures/big_glow.png" type="Texture" id=3] [ext_resource path="res://modules/entity_classes/naturalist/spell_effects/textures/main_texture.png" type="Texture" id=4] +[node name="NatureCast" type="Node2D"] +[node name="big_glow" type="Sprite" parent="."] +modulate = Color( 0.027451, 0.537255, 0.317647, 1 ) +texture = ExtResource( 3 ) -[sub_resource type="ShaderMaterial" id=1] -shader = ExtResource( 2 ) -shader_param/albedo = Color( 1, 1, 1, 1 ) -shader_param/texture_albedo = ExtResource( 4 ) - -[sub_resource type="QuadMesh" id=2] -material = SubResource( 1 ) -size = Vector2( 0.1, 0.1 ) - -[sub_resource type="ShaderMaterial" id=3] -shader = ExtResource( 1 ) -shader_param/albedo = Color( 0.027451, 0.537255, 0.317647, 1 ) -shader_param/texture_albedo = ExtResource( 3 ) - -[sub_resource type="QuadMesh" id=4] -material = SubResource( 3 ) -size = Vector2( 0.3, 0.3 ) - -[node name="NatureCast" type="Spatial"] - -[node name="CPUParticles" type="CPUParticles" parent="."] +[node name="CPUParticles2D" type="CPUParticles2D" parent="."] amount = 5 lifetime = 0.29 explosiveness = 0.08 randomness = 0.77 lifetime_randomness = 1.0 -local_coords = false -mesh = SubResource( 2 ) +texture = ExtResource( 4 ) emission_shape = 1 -emission_sphere_radius = 0.1 -direction = Vector3( 1, 1, 1 ) +emission_sphere_radius = 4.97 +direction = Vector2( 1, 1 ) spread = 180.0 -gravity = Vector3( 0, -9, 0 ) -initial_velocity = 1.0 -initial_velocity_random = 1.0 angular_velocity = 397.64 angular_velocity_random = 0.2 -radial_accel = 1.0 tangential_accel = 6.9 tangential_accel_random = 0.21 damping = 6.54 damping_random = 0.5 angle = 426.5 angle_random = 1.0 -scale_amount = 0.3 -scale_amount_random = 1.0 +scale_amount = 0.17 +scale_amount_random = 0.51 color = Color( 0.0901961, 0.501961, 0.247059, 1 ) - -[node name="MeshInstance" type="MeshInstance" parent="."] -mesh = SubResource( 4 ) -material/0 = null diff --git a/game/modules/entity_classes/naturalist/spell_effects/nature/NautreSwiftness.tscn b/game/modules/entity_classes/naturalist/spell_effects/nature/NautreSwiftness.tscn index 08d1dc3..7d3aa1e 100644 --- a/game/modules/entity_classes/naturalist/spell_effects/nature/NautreSwiftness.tscn +++ b/game/modules/entity_classes/naturalist/spell_effects/nature/NautreSwiftness.tscn @@ -4,9 +4,6 @@ [ext_resource path="res://modules/core/shaders/3_simple_y_billboard.shader" type="Shader" id=2] [ext_resource path="res://modules/core/materials/2_simple_particle_billboard.tres" type="Material" id=3] - - - [sub_resource type="QuadMesh" id=1] material = ExtResource( 3 ) size = Vector2( 0.02, 0.02 ) diff --git a/game/player/CharacterSkeletonAttachPoint.gd b/game/player/CharacterSkeletonAttachPoint.gd index 178058f..96fff5f 100644 --- a/game/player/CharacterSkeletonAttachPoint.gd +++ b/game/player/CharacterSkeletonAttachPoint.gd @@ -1,10 +1,11 @@ -extends Spatial +tool +extends Node2D class_name CharacterSkeketonAttachPoint # Copyright Péter Magyar relintai@gmail.com # MIT License, functionality from this class needs to be protable to the entity spell system -# Copyright (c) 2019 Péter Magyar +# Copyright (c) 2019-2020 Péter Magyar # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,7 +28,7 @@ class_name CharacterSkeketonAttachPoint var effects : Dictionary var timed_effects : Dictionary -func add_effect(effect : PackedScene) -> void: +func add(effect : PackedScene) -> void: if effects.has(effect): effects[effect][0] = effects[effect][0] + 1 else: @@ -39,7 +40,7 @@ func add_effect(effect : PackedScene) -> void: var data : Array = [ 1, eff ] effects[effect] = data -func add_effect_timed(effect : PackedScene, time : float) -> void: +func add_timed(effect : PackedScene, time : float) -> void: if timed_effects.has(effect): timed_effects[effect][0] = timed_effects[effect][0] + 1 else: @@ -51,7 +52,7 @@ func add_effect_timed(effect : PackedScene, time : float) -> void: var data : Array = [ 1, eff, time ] timed_effects[effect] = data -func remove_effect(effect : PackedScene) -> void: +func remove(effect : PackedScene) -> void: if effects.has(effect): var data : Array = effects[effect] diff --git a/game/project.godot b/game/project.godot index c45e69d..5e2cdd4 100644 --- a/game/project.godot +++ b/game/project.godot @@ -24,7 +24,7 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://scripts/item_visuals/CharacterAtlasEntry2D.gd" }, { -"base": "Spatial", +"base": "Node2D", "class": "CharacterSkeketonAttachPoint", "language": "GDScript", "path": "res://player/CharacterSkeletonAttachPoint.gd"