diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2022-10-19 14:13:47 -0400 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2022-10-19 14:13:47 -0400 |
| commit | 5100ec45264ff36a2558757e76198b8b25866992 (patch) | |
| tree | cd1fd239fe0380028c1d77e456a49ecf186830d6 /godot/scripts/characters | |
| parent | e826b74a104e72ec398aa55bd5dceb13b5a0dae1 (diff) | |
server work
Diffstat (limited to 'godot/scripts/characters')
| -rw-r--r-- | godot/scripts/characters/NetworkedCharacter.gd | 15 | ||||
| -rw-r--r-- | godot/scripts/characters/player_controller_new.gd | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/godot/scripts/characters/NetworkedCharacter.gd b/godot/scripts/characters/NetworkedCharacter.gd index c14d46f..8a0282d 100644 --- a/godot/scripts/characters/NetworkedCharacter.gd +++ b/godot/scripts/characters/NetworkedCharacter.gd @@ -71,17 +71,22 @@ func lose_machine(): controlling_machine = false machine = null -remotesync func damage(dmg_amt: int, _type: String, shooter: Array, extra: String): +#args format +#attacker_net_id +#attacker_name +#damage_type +#weapon_name +remotesync func damage(dmg_amt: int, args: Dictionary): print(dmg_amt) health -= dmg_amt if health <= 0 and is_network_master(): - if shooter[0] != get_network_master() and shooter[0] != 1: world.rpc_id(shooter[0], "game_killsound") + if args["attacker_net_id"] != get_network_master() and args["attacker_net_id"] != 1: world.rpc_id(args["attacker_net_id"], "game_killsound") if get_network_master() == 1: - world._call_on_server("_character_death", {"killer_id" : shooter[0], "killer" : shooter[1], "victim_mp_id" : get_network_master(), "victim" : name, "extra" : extra}) + world._call_on_server("_character_death", {"killer_id" : args["attacker_net_id"], "killer_name" : args["attacker_name"], "victim_mp_id" : get_network_master(), "victim_name" : name, "extra" : args["weapon_name"]}) else: - world.rpc_id(1, "_call_on_server", "_character_death", {"killer_id" : shooter[0], "killer" : shooter[1], "victim_mp_id" : get_network_master(), "victim" : name, "extra" : extra}) + world.rpc_id(1, "_call_on_server", "_character_death", {"killer_id" : args["attacker_net_id"], "killer_name" : args["attacker_name"], "victim_mp_id" : get_network_master(), "victim_name" : name, "extra" : args["weapon_name"]}) elif is_network_master(): - if shooter[0] != get_network_master() and shooter[0] != 1: world.rpc_id(shooter[0], "game_hitsound") + if args["attacker_net_id"] != get_network_master() and args["attacker_net_id"] != 1: world.rpc_id(args["attacker_net_id"], "game_hitsound") remotesync func remove_dead_character(): if is_network_master() and machine != null: diff --git a/godot/scripts/characters/player_controller_new.gd b/godot/scripts/characters/player_controller_new.gd index 6d45415..d78b6e3 100644 --- a/godot/scripts/characters/player_controller_new.gd +++ b/godot/scripts/characters/player_controller_new.gd @@ -38,6 +38,8 @@ export var walk_speed:float = 5.0 var c_friction:float = 4.0 var air_control:float = 0.3 +var idle_t: bool = true + #ai onready var ai_state_machine:StateMachine = get_node("AIStateMachine") enum AIStates { IDLE, MAN_CANNON } @@ -57,6 +59,8 @@ var ai_should_track: bool = false var ai_track_object: Spatial = null const AI_LOOK_SPEED: float = 4.0 +const DROWN_DICT: Dictionary = {"type" : "DROWN", "attacker_net_id" : 1, "attacker_name" : "Davy Jones", "weapon_name" : "his locker"} + # Called when the node enters the scene tree func _ready() -> void: if weapon_slot1 == null: @@ -269,7 +273,7 @@ func _integrate_forces(state: PhysicsDirectBodyState) -> void: rpc("set_phys_transform", transform, linear_velocity) if global_transform.origin.y < -30: - rpc("damage", 500000, "drown", [1, "Davy Jones"], "") + rpc("damage", 500000, DROWN_DICT) nav.set_velocity(velocity) @@ -354,7 +358,7 @@ func leave_ladder(): if (ladder_m.get_parent().top.global_transform.origin - global_transform.origin).length_squared() < 0.01: apply_central_impulse(-400*ladder_m.global_transform.basis.z) global_transform.basis = world.global_transform.basis - neck.set_global_rotation(old_neck_rot) + neck.set_global_rotation(Vector3(0,old_neck_rot.y,0)) set_gravity_scale(1.0) ladder_m.queue_free() ladder_m = null |
