Prikoliki

This commit is contained in:
Rendo 2025-12-14 15:52:38 +05:00
commit 66fbad750c
22 changed files with 11192 additions and 42 deletions

View file

@ -20,6 +20,7 @@ enum ROUND_STATES {
const WIN_MONEY: int = 3400
const LOSE_MONEY: int = 2000
const START_MONEY: int = 800
const ATTACK_LAYER: int = 0b10000
const DEFENCE_LAYER: int = 0b100000
@ -55,6 +56,7 @@ var bomb_timer: Timer
var round_timer: Timer
var buy_timer: Timer
func _ready() -> void:
if multiplayer.is_server() == false:
return
@ -155,8 +157,9 @@ func start_session() -> void:
all_players.append(multiplayer.get_unique_id())
for player in all_players:
player_data[player] = {
"money" : 800,
"nickname" : "Seliboba"
"money" : START_MONEY,
"nickname" : Lobby.client_nicknames[player],
"saved_slots" : {}
}
start_round()
@ -178,6 +181,8 @@ func end_session() -> void:
session_started_flag = false
plants = []
plant_deadzones = {}
player_nodes.clear()
player_data.clear()
dynamic_objects_parent = null
@ -200,6 +205,21 @@ func start_round() -> void:
start_round.rpc()
round_timer.stop()
bomb_timer.stop()
if not current_round == LobbySettings.half_rounds:
for player_id in player_nodes.keys():
var player: Player = player_nodes[player_id]
if player.dead:
player_data[player_id].saved_slots = {}
continue
var weapon_system: WeaponSystem = player.get_node("%WeaponSystem")
var saved_slots: Dictionary[StringName,StringName] = {}
for slot in weapon_system.slots:
if slot == "bomb" or slot == "knife" or weapon_system.slots[slot] == null:
continue
saved_slots[slot] = weapon_system.slots[slot].weapon_gid
player_data[player_id].saved_slots = saved_slots
for container in object_containers:
container.despawn()
attackers_alive = 0
@ -246,6 +266,9 @@ func end_round(win_team: int) -> void:
var temp_rounds = attacker_score
attacker_score = defender_score
defender_score = temp_rounds
for id in player_data:
player_data[id].money = START_MONEY
player_data[id].saved_slots = {}
sync_score.rpc(attacker_score,defender_score)
round_state = ROUND_STATES.AFTER_ROUND
@ -347,14 +370,14 @@ func shoot(id:int , limb_damage: int, torso_damage: int,head_damage: int, distan
reduction = damage_reduction_curve.sample(distance_to_hit)
hit_player.take_damage(int(float(damage) * reduction))
var bullet_hole: Decal = BULLET_HOLE.instantiate()
dynamic_objects_parent.add_child(bullet_hole,true)
var rotation_quat: Quaternion = Quaternion(Vector3.UP,collision["normal"])
bullet_hole.quaternion *= rotation_quat
bullet_hole.global_position = collision["position"]
else:
var bullet_hole: Decal = BULLET_HOLE.instantiate()
dynamic_objects_parent.add_child(bullet_hole,true)
var rotation_quat: Quaternion = Quaternion(Vector3.UP,collision["normal"])
bullet_hole.quaternion *= rotation_quat
bullet_hole.global_position = collision["position"]
func shoot_pellets(id:int,limb_pellet_damage: int, torso_pellet_damage: int,head_pellet_damage: int, distance: float, pellets: PackedVector2Array, damage_reduction_curve: Curve = null):
@ -404,14 +427,14 @@ func shoot_pellets(id:int,limb_pellet_damage: int, torso_pellet_damage: int,head
reduction = damage_reduction_curve.sample(distance_to_hit)
hit_player.take_damage(int(float(damage) * reduction))
var bullet_hole: Decal = BULLET_HOLE.instantiate()
dynamic_objects_parent.add_child(bullet_hole,true)
var rotation_quat: Quaternion = Quaternion(Vector3.UP,collision["normal"])
bullet_hole.quaternion *= rotation_quat
bullet_hole.global_position = collision["position"]
else:
var bullet_hole: Decal = BULLET_HOLE.instantiate()
dynamic_objects_parent.add_child(bullet_hole,true)
var rotation_quat: Quaternion = Quaternion(Vector3.UP,collision["normal"])
bullet_hole.quaternion *= rotation_quat
bullet_hole.global_position = collision["position"]
func interact(id: int) -> void:
if multiplayer.is_server() == false:
@ -474,7 +497,8 @@ func delete_player(id: int):
delete_player.rpc_id(id)
player_data.erase(id)
# For clients only
func get_player_data() -> Dictionary:
var id: int = multiplayer.get_unique_id()
if player_data.has(id):