fixed errors, implemented different weapons, code cleanup

This commit is contained in:
leca 2024-02-18 01:35:54 +03:00
parent de44ff2cce
commit 76b8dc3a17
11 changed files with 879 additions and 38 deletions

9
models/ak_47.tscn Normal file
View File

@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3 uid="uid://caos4gg5cd6f6"]
[ext_resource type="PackedScene" uid="uid://dndsa6rm6hovq" path="res://models/automatto.dae" id="1_kapkd"]
[node name="ak-47" type="Node3D"]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, -0.570068, 0, 0)
[node name="automatto" parent="." instance=ExtResource("1_kapkd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.18626, -1.25157, 0)

485
models/automatto.dae Normal file
View File

@ -0,0 +1,485 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Anonymous</author>
<authoring_tool>Collada Exporter for Blender 2.6+, by Juan Linietsky (juan@codenix.com)</authoring_tool>
</contributor>
<created>2024-02-17T21:56:07Z</created>
<modified>2024-02-17T21:56:07Z</modified>
<unit meter="1.0" name="meter"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_effects>
<effect id="id-fx-2" name="Material-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<emission>
<color> 0.800000011920929 0.800000011920929 0.800000011920929 1.0 </color>
</emission>
<ambient>
<color> 0.0 0.0 0.0 1.0 </color>
</ambient>
<diffuse>
<color> 0.6400000095367432 0.6400000095367432 0.6400000095367432 0.8 </color>
</diffuse>
<specular>
<color> 0.5 0.5 0.5 1.0 </color>
</specular>
<shininess>
<float>50</float>
</shininess>
<reflective>
<color> 0.5 0.5 0.5 1.0 </color>
</reflective>
<index_of_refraction>
<float>1.2</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
</technique>
<technique profile="GOOGLEEARTH">
<double_sided>1</double_sided>
</technique>
</extra>
</technique>
</profile_COMMON>
</effect>
<effect id="id-fx-6" name="Material.001-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<emission>
<color> 0.800000011920929 0.800000011920929 0.800000011920929 1.0 </color>
</emission>
<ambient>
<color> 0.0 0.0 0.0 1.0 </color>
</ambient>
<diffuse>
<color> 0.6400000095367432 0.6400000095367432 0.6400000095367432 0.8 </color>
</diffuse>
<specular>
<color> 0.5 0.5 0.5 1.0 </color>
</specular>
<shininess>
<float>50</float>
</shininess>
<reflective>
<color> 0.5 0.5 0.5 1.0 </color>
</reflective>
<index_of_refraction>
<float>1.2</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
</technique>
<technique profile="GOOGLEEARTH">
<double_sided>1</double_sided>
</technique>
</extra>
</technique>
</profile_COMMON>
</effect>
<effect id="id-fx-10" name="Material.002-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<emission>
<color> 0.800000011920929 0.800000011920929 0.800000011920929 1.0 </color>
</emission>
<ambient>
<color> 0.0 0.0 0.0 1.0 </color>
</ambient>
<diffuse>
<color> 0.6400000095367432 0.6400000095367432 0.6400000095367432 0.8 </color>
</diffuse>
<specular>
<color> 0.5 0.5 0.5 1.0 </color>
</specular>
<shininess>
<float>50</float>
</shininess>
<reflective>
<color> 0.5 0.5 0.5 1.0 </color>
</reflective>
<index_of_refraction>
<float>1.2</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
</technique>
<technique profile="GOOGLEEARTH">
<double_sided>1</double_sided>
</technique>
</extra>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="id-material-3" name="Material">
<instance_effect url="#id-fx-2"/>
</material>
<material id="id-material-7" name="Material.001">
<instance_effect url="#id-fx-6"/>
</material>
<material id="id-material-11" name="Material.002">
<instance_effect url="#id-fx-10"/>
</material>
</library_materials>
<library_geometries>
<geometry id="id-mesh-4" name="Cube">
<mesh>
<source id="id-mesh-4-positions">
<float_array id="id-mesh-4-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-4-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-4-normals">
<float_array id="id-mesh-4-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-4-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-4-texcoord-0">
<float_array id="id-mesh-4-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-4-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-4-vertices">
<input semantic="POSITION" source="#id-mesh-4-positions"/>
</vertices>
<polygons count="6" material="id-trimat-5">
<input semantic="VERTEX" source="#id-mesh-4-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-4-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-4-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-8" name="Cube.001">
<mesh>
<source id="id-mesh-8-positions">
<float_array id="id-mesh-8-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-8-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-8-normals">
<float_array id="id-mesh-8-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-8-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-8-texcoord-0">
<float_array id="id-mesh-8-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-8-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-8-vertices">
<input semantic="POSITION" source="#id-mesh-8-positions"/>
</vertices>
<polygons count="6" material="id-trimat-9">
<input semantic="VERTEX" source="#id-mesh-8-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-8-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-8-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-12" name="Cube.002">
<mesh>
<source id="id-mesh-12-positions">
<float_array id="id-mesh-12-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-12-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-12-normals">
<float_array id="id-mesh-12-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-12-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-12-texcoord-0">
<float_array id="id-mesh-12-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-12-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-12-vertices">
<input semantic="POSITION" source="#id-mesh-12-positions"/>
</vertices>
<polygons count="6" material="id-trimat-13">
<input semantic="VERTEX" source="#id-mesh-12-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-12-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-12-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-14" name="Cube.003">
<mesh>
<source id="id-mesh-14-positions">
<float_array id="id-mesh-14-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-14-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-14-normals">
<float_array id="id-mesh-14-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-14-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-14-texcoord-0">
<float_array id="id-mesh-14-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-14-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-14-vertices">
<input semantic="POSITION" source="#id-mesh-14-positions"/>
</vertices>
<polygons count="6" material="id-trimat-15">
<input semantic="VERTEX" source="#id-mesh-14-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-14-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-14-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-16" name="Cube.004">
<mesh>
<source id="id-mesh-16-positions">
<float_array id="id-mesh-16-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-16-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-16-normals">
<float_array id="id-mesh-16-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-16-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-16-texcoord-0">
<float_array id="id-mesh-16-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-16-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-16-vertices">
<input semantic="POSITION" source="#id-mesh-16-positions"/>
</vertices>
<polygons count="6" material="id-trimat-17">
<input semantic="VERTEX" source="#id-mesh-16-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-16-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-16-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-18" name="Cube.005">
<mesh>
<source id="id-mesh-18-positions">
<float_array id="id-mesh-18-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-18-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-18-normals">
<float_array id="id-mesh-18-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-18-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-18-texcoord-0">
<float_array id="id-mesh-18-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-18-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-18-vertices">
<input semantic="POSITION" source="#id-mesh-18-positions"/>
</vertices>
<polygons count="6" material="id-trimat-19">
<input semantic="VERTEX" source="#id-mesh-18-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-18-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-18-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
</library_geometries>
<library_visual_scenes>
<visual_scene id="id-scene-1" name="scene">
<node id="Cube" name="Cube" type="NODE">
<matrix sid="transform"> 2.6000001430511475 0.0 0.0 0.0 0.0 0.19977541267871857 0.0 0.0 0.0 0.0 0.4598263204097748 2.203359842300415 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-4">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-5" target="#id-material-3"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.001" name="Cube.001" type="NODE">
<matrix sid="transform"> -1.57242467935248e-08 0.0009324373677372932 0.2314780056476593 1.6276607513427734 1.6476175090929246e-08 0.11205510795116425 -0.0019261838169768453 -0.012317478656768799 -0.5210391283035278 3.515240321050328e-09 -7.046598859972164e-09 1.4152696132659912 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-8">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-9" target="#id-material-7"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.002" name="Cube.002" type="NODE">
<matrix sid="transform"> 0.012317821383476257 0.0 -0.23190557956695557 -1.2648444175720215 0.0 0.11228424310684204 0.0 -0.016380950808525085 0.9720970988273621 0.0 0.002938566030934453 1.156082034111023 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-12">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-13" target="#id-material-11"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.003" name="Cube.003" type="NODE">
<matrix sid="transform"> 0.4965575635433197 0.0 0.0 2.8978543281555176 0.0 0.16011132299900055 0.0 -0.0013670185580849648 0.0 0.0 0.24370159208774567 2.1922411918640137 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-14">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-15" target="#id-material-7"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.004" name="Cube.004" type="NODE">
<matrix sid="transform"> 0.4965575635433197 0.0 0.0 3.762096643447876 0.0 0.19658255577087402 0.0 -0.0028609037399291992 0.0 0.0 0.28466933965682983 2.1854066848754883 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-16">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-17" target="#id-material-7"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.005" name="Cube.005" type="NODE">
<matrix sid="transform"> 0.3889171779155731 0.0 0.0 -2.7596819400787354 0.0 0.06061943992972374 0.0 0.0 0.0 0.0 0.06876473128795624 2.203359842300415 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-18">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-19" target="#id-material-11"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#id-scene-1" />
</scene>
</COLLADA>

View File

@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dndsa6rm6hovq"
path="res://.godot/imported/automatto.dae-432f9c65d99e4ae982cd03115d636026.scn"
[deps]
source_file="res://models/automatto.dae"
dest_files=["res://.godot/imported/automatto.dae-432f9c65d99e4ae982cd03115d636026.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

8
models/pistol.tscn Normal file
View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://cnu1vf8k5i3tv"]
[ext_resource type="PackedScene" uid="uid://hf47u08p80fo" path="res://models/pistoletto.dae" id="1_hdcb6"]
[node name="pistol" type="Node3D"]
[node name="pistoletto" parent="." instance=ExtResource("1_hdcb6")]
transform = Transform3D(0.21, 0, 0, 0, 0.21, 0, 0, 0, 0.21, 0, 0, 0)

218
models/pistoletto.dae Normal file
View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>Anonymous</author>
<authoring_tool>Collada Exporter for Blender 2.6+, by Juan Linietsky (juan@codenix.com)</authoring_tool>
</contributor>
<created>2024-02-17T21:50:36Z</created>
<modified>2024-02-17T21:50:36Z</modified>
<unit meter="1.0" name="meter"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_effects>
<effect id="id-fx-2" name="Material.002-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<emission>
<color> 0.800000011920929 0.800000011920929 0.800000011920929 1.0 </color>
</emission>
<ambient>
<color> 0.0 0.0 0.0 1.0 </color>
</ambient>
<diffuse>
<color> 0.6400000095367432 0.6400000095367432 0.6400000095367432 0.8 </color>
</diffuse>
<specular>
<color> 0.5 0.5 0.5 1.0 </color>
</specular>
<shininess>
<float>50</float>
</shininess>
<reflective>
<color> 0.5 0.5 0.5 1.0 </color>
</reflective>
<index_of_refraction>
<float>1.2</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
</technique>
<technique profile="GOOGLEEARTH">
<double_sided>1</double_sided>
</technique>
</extra>
</technique>
</profile_COMMON>
</effect>
<effect id="id-fx-6" name="Material.001-fx">
<profile_COMMON>
<technique sid="common">
<blinn>
<emission>
<color> 0.800000011920929 0.800000011920929 0.800000011920929 1.0 </color>
</emission>
<ambient>
<color> 0.0 0.0 0.0 1.0 </color>
</ambient>
<diffuse>
<color> 0.6400000095367432 0.6400000095367432 0.6400000095367432 0.8 </color>
</diffuse>
<specular>
<color> 0.5 0.5 0.5 1.0 </color>
</specular>
<shininess>
<float>50</float>
</shininess>
<reflective>
<color> 0.5 0.5 0.5 1.0 </color>
</reflective>
<index_of_refraction>
<float>1.2</float>
</index_of_refraction>
</blinn>
<extra>
<technique profile="FCOLLADA">
</technique>
<technique profile="GOOGLEEARTH">
<double_sided>1</double_sided>
</technique>
</extra>
</technique>
</profile_COMMON>
</effect>
</library_effects>
<library_materials>
<material id="id-material-3" name="Material.002">
<instance_effect url="#id-fx-2"/>
</material>
<material id="id-material-7" name="Material.001">
<instance_effect url="#id-fx-6"/>
</material>
</library_materials>
<library_geometries>
<geometry id="id-mesh-4" name="Cube">
<mesh>
<source id="id-mesh-4-positions">
<float_array id="id-mesh-4-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-4-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-4-normals">
<float_array id="id-mesh-4-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-4-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-4-texcoord-0">
<float_array id="id-mesh-4-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-4-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-4-vertices">
<input semantic="POSITION" source="#id-mesh-4-positions"/>
</vertices>
<polygons count="6" material="id-trimat-5">
<input semantic="VERTEX" source="#id-mesh-4-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-4-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-4-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
<geometry id="id-mesh-8" name="Cube.001">
<mesh>
<source id="id-mesh-8-positions">
<float_array id="id-mesh-8-positions-array" count="72"> 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 1.0 -1.0 1.0 1.0 -1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0</float_array>
<technique_common>
<accessor source="#id-mesh-8-positions-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-8-normals">
<float_array id="id-mesh-8-normals-array" count="72"> 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0</float_array>
<technique_common>
<accessor source="#id-mesh-8-normals-array" count="24" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="id-mesh-8-texcoord-0">
<float_array id="id-mesh-8-texcoord-0-array" count="48"> 0.625 0.5 0.875 0.5 0.875 0.75 0.625 0.75 0.375 0.75 0.625 0.75 0.625 1.0 0.375 1.0 0.375 0.0 0.625 0.0 0.625 0.25 0.375 0.25 0.125 0.5 0.375 0.5 0.375 0.75 0.125 0.75 0.375 0.5 0.625 0.5 0.625 0.75 0.375 0.75 0.375 0.25 0.625 0.25 0.625 0.5 0.375 0.5</float_array>
<technique_common>
<accessor source="#id-mesh-8-texcoord-0-array" count="24" stride="2">
<param name="S" type="float"/>
<param name="T" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="id-mesh-8-vertices">
<input semantic="POSITION" source="#id-mesh-8-positions"/>
</vertices>
<polygons count="6" material="id-trimat-9">
<input semantic="VERTEX" source="#id-mesh-8-vertices" offset="0"/>
<input semantic="NORMAL" source="#id-mesh-8-normals" offset="0"/>
<input semantic="TEXCOORD" source="#id-mesh-8-texcoord-0" offset="0" set="0"/>
<p> 0 1 2 3 </p>
<p> 4 5 6 7 </p>
<p> 8 9 10 11 </p>
<p> 12 13 14 15 </p>
<p> 16 17 18 19 </p>
<p> 20 21 22 23 </p>
</polygons>
</mesh>
</geometry>
</library_geometries>
<library_visual_scenes>
<visual_scene id="id-scene-1" name="scene">
<node id="Cube" name="Cube" type="NODE">
<matrix sid="transform"> 0.28390204906463623 0.0 0.30559131503105164 -0.016092630103230476 0.0 0.11151131987571716 0.0 0.0 -0.7800144553184509 0.0 0.1112261414527893 -0.06142665445804596 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-4">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-5" target="#id-material-3"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
<node id="Cube.001" name="Cube.001" type="NODE">
<matrix sid="transform"> 1.2125928401947021 0.0 0.0 -1.1341843605041504 0.0 0.12897871434688568 0.0 0.0 0.0 0.0 0.33654701709747314 0.5419423580169678 0.0 0.0 0.0 1.0 </matrix>
<instance_geometry url="#id-mesh-8">
<bind_material>
<technique_common>
<instance_material symbol="id-trimat-9" target="#id-material-7"/>
</technique_common>
</bind_material>
</instance_geometry>
</node>
</visual_scene>
</library_visual_scenes>
<scene>
<instance_visual_scene url="#id-scene-1" />
</scene>
</COLLADA>

View File

@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://hf47u08p80fo"
path="res://.godot/imported/pistoletto.dae-4af72fbdd439456c2e42ffc84bc67388.scn"
[deps]
source_file="res://models/pistoletto.dae"
dest_files=["res://.godot/imported/pistoletto.dae-4af72fbdd439456c2e42ffc84bc67388.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=5 format=3 uid="uid://b2jhgtduapovl"]
[gd_scene load_steps=8 format=3 uid="uid://b2jhgtduapovl"]
[ext_resource type="Script" path="res://scripts/Player.gd" id="1_o6o4b"]
[ext_resource type="PackedScene" uid="uid://cnu1vf8k5i3tv" path="res://models/pistol.tscn" id="2_nxbij"]
[ext_resource type="PackedScene" uid="uid://caos4gg5cd6f6" path="res://models/ak_47.tscn" id="3_r56e3"]
[sub_resource type="CylinderMesh" id="CylinderMesh_hyaut"]
[sub_resource type="SphereMesh" id="SphereMesh_fp0bl"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_yyp7b"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_jqfxo"]
@ -27,6 +31,20 @@ transform = Transform3D(0.368235, 0, 0, 0, -4.37934e-08, -0.354994, 0, 1.00188,
mesh = SubResource("CylinderMesh_hyaut")
skeleton = NodePath("../..")
[node name="Hand" type="Node3D" parent="CharacterBody3D/Head/Camera"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0.72454, -0.463491, -0.808041)
[node name="knife" type="MeshInstance3D" parent="CharacterBody3D/Head/Camera/Hand"]
transform = Transform3D(0.16, 0, 0, 0, 0.16, 0, 0, 0, 0.16, 0, 0, 0)
visible = false
mesh = SubResource("SphereMesh_fp0bl")
[node name="pistol" parent="CharacterBody3D/Head/Camera/Hand" instance=ExtResource("2_nxbij")]
visible = false
[node name="ak-47" parent="CharacterBody3D/Head/Camera/Hand" instance=ExtResource("3_r56e3")]
visible = false
[node name="Nickname" type="Label3D" parent="CharacterBody3D/Head"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.24983, 0)
billboard = 1

View File

@ -1,5 +1,11 @@
extends Node
var Weapons = {
"knife" = 0,
"pistol" = 1,
"ak-47" = 2
}
var client_settings
var server_settings

View File

@ -2,7 +2,7 @@ extends Node
var player_script := preload("res://scripts/Player.gd")
var server_map
@onready var Weapons = GameData.Weapons
var player_model = preload("res://models/player.tscn")
var peer = ENetMultiplayerPeer.new()
var settings
@ -63,13 +63,11 @@ func _Peer_Connected(client_id):
clients[client_id] = player_script.new().properties.duplicate()
clients[client_id]["position"] = Vector3(0, 10, 0)
clients[client_id]["internal_id"] = internal_id
clients[client_id]["is_playable"] = false
var puppet = player_model.instantiate()
var CB3D = puppet.find_child("CharacterBody3D")
CB3D.set_is_playable(false)
CB3D.set_internal_id(internal_id)
CB3D.set_player_name("player" + str(internal_id))
CB3D.set_nickname(clients[client_id]["nickname"])
CB3D.set_properties(clients[client_id])
server_map.add_child(puppet)
@ -143,14 +141,28 @@ func shot(client_id):
for checking_client_id in clients.keys():
if (clients[checking_client_id]["internal_id"] == target_internal_id):
target_client = clients[checking_client_id]
var target_cb3d = find_cb3d_by_internal_id(internal_id)
target_client["HP"] -= 10;
var target_cb3d = find_cb3d_by_internal_id(target_internal_id)
var target_client_id = int(clients.find_key(target_client))
if (target_client["HP"] == 0):
target_cb3d.teleport.rpc_id(int(clients.find_key(target_client)), Vector3(0, 10, 0))
var current_weapon = Weapons.find_key(client["current_weapon"])
var damage = settings["game"]["weapons"][current_weapon]["damage"];
target_client["HP"] -= damage
if (target_client["HP"] <= 0):
target_cb3d.teleport.rpc_id(target_client_id, Vector3(0, 10, 0))
target_client["HP"] = 100
target_cb3d.set_hp.rpc_id(int(clients.find_key(target_client)), target_client["HP"])
target_cb3d.set_hp.rpc_id(target_client_id, target_client["HP"])
@rpc("reliable", "call_remote", "any_peer")
func change_weapon(client_id, new_weapon):
var client = clients[client_id]
var internal_id = str(client["internal_id"])
client["current_weapon"] = new_weapon
var client_cb3d = find_cb3d_by_internal_id(internal_id)
client_cb3d.change_weapon(new_weapon)
send_everyone_except(client_id, [client_cb3d.change_weapon_puppet, internal_id, new_weapon])
#client_cb3d.change_weapon_puppet.rpc_id(client_id, new_weapon)
##########################################CLIENT#######################
var player
@ -166,14 +178,9 @@ func set_character_properties(p):
@rpc("authority", "reliable", "call_remote")
func spawn_puppet(properties):
var puppet = player_model.instantiate()
var internal_id = int(properties["internal_id"])
var CB3D = puppet.find_child("CharacterBody3D")
CB3D.set_is_playable(false)
CB3D.set_internal_id(internal_id)
CB3D.set_player_name("player" + str(internal_id))
CB3D.set_nickname(properties["nickname"])
CB3D.set_ready(true)
puppet.name = "player" + str(internal_id)
properties["ready"] = true
CB3D.set_properties(properties.duplicate())
current_map_instance.add_child(puppet)
@ -215,11 +222,11 @@ func _Connection_Succseeded():
var player_node = player_model.instantiate()
var CB3D = player_node.find_child("CharacterBody3D")
CB3D.set_is_playable(true)
CB3D.set_internal_id(player["internal_id"])
CB3D.set_player_name("player" + str(player["internal_id"]))
CB3D.set_nickname(nickname)
CB3D.set_ready(true)
var properties = player_script.new().properties.duplicate()
properties = player
properties["is_playable"] = true
properties["ready"] = true
CB3D.set_properties(properties)
current_map_instance.add_child(player_node)
await get_tree().create_timer(0.05).timeout # костыль

View File

@ -16,6 +16,8 @@ enum Class_type {
Windows10 = -5
}
var Weapons = GameData.Weapons
var properties = {
HP = 100,
AP = 100,
@ -24,7 +26,8 @@ var properties = {
is_playable = false,
internal_id = 0,
nickname = "Unnamed",
ready = false
ready = false,
current_weapon = 0
}
var speed = 0
@ -34,6 +37,7 @@ var jump = 0
var gravity = 0
var game_settings
var client_settings
var current_weapon = Weapons["knife"]
@onready var head = $Head
@onready var camera = $Head/Camera
@ -41,25 +45,20 @@ var client_settings
var HUD
var healthBar
func set_ready(value):
properties["ready"] = value;
func set_properties(props):
properties = props
$"..".name = "player" + str(properties["internal_id"])
func set_player_name (n):
$"..".name = n
func set_nickname (n):
properties["nickname"] = n
GameData.client_settings["nickname"] = n
func set_internal_id(id):
print("Setting internal_id to " + str(id))
properties["internal_id"] = id
func set_is_playable(value):
properties["is_playable"] = value
func change_weapon(new_weapon):
var weapons = $"Head/Camera/Hand".get_children()
for weapon in weapons:
weapon.visible = false
weapons[new_weapon].visible = true
func _ready():
$"Head/Nickname".text = properties["nickname"]
change_weapon(properties["current_weapon"])
if (!properties["is_playable"]): return
camera.make_current()
var hud = load("res://scenes/hud.tscn").instantiate()
@ -72,6 +71,15 @@ func _ready():
func _unhandled_input(event):
if (!properties["is_playable"]): return
if Input.is_action_pressed("MWU"):
properties["current_weapon"] = wrap(properties["current_weapon"] + 1, 0, Weapons.size())
Networking.change_weapon.rpc_id(1, multiplayer.get_unique_id(), properties["current_weapon"])
if Input.is_action_pressed("MWD"):
properties["current_weapon"] = wrap(properties["current_weapon"] - 1, 0, Weapons.size())
Networking.change_weapon.rpc_id(1, multiplayer.get_unique_id(), properties["current_weapon"])
change_weapon(properties["current_weapon"])
if(event.is_action_pressed("shoot")):
print(event.position)
Networking.shot.rpc_id(1, multiplayer.get_unique_id())
@ -127,6 +135,7 @@ func sync_puppet(i_id, p, rot):
@rpc ("authority", "call_remote", "reliable")
func set_hp(hp):
print("Got new hp" + str(hp))
if (!properties["is_playable"]): return
properties["HP"] = hp
healthBar.value = properties["HP"]
@ -145,3 +154,9 @@ func set_game_settings(s):
@rpc ("authority", "call_remote", "reliable")
func teleport(pos):
$".".position = pos
print("Teleporing to " + str(pos))
@rpc ("authority", "call_remote", "reliable")
func change_weapon_puppet(i_id, new_weapon):
if (int(i_id) == properties["internal_id"]):
change_weapon(new_weapon)

View File

@ -10,6 +10,13 @@
"jump": 12
},
"weapons": {
"knife": {
"damage": 50,
"reload": 3,
"magazine": 1,
"fireFate": 3,
"spreading": 0
},
"pistol": {
"damage": 10,
"reload": 2,