From 1422992c13325483e14777ec6e611715149bd8d3 Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 28 Mar 2025 08:35:21 -0500 Subject: [PATCH] fixed checksum and added seed-based chest spawning order --- GameModes/DoNotGetHit.tres | 1 + GameModes/standard_stam_regen.tres | 1 + Tools/playlist_generator.tscn | 1 - assets/LevelBlockouts/hub_1.tscn | 6 +++- assets/scene_changer.tscn | 2 +- scripts/HelperFuncs.gd | 52 +++++++++--------------------- scripts/playlist_generator.gd | 9 +++++- scripts/weapon_uberscript.gd | 1 - 8 files changed, 31 insertions(+), 42 deletions(-) diff --git a/GameModes/DoNotGetHit.tres b/GameModes/DoNotGetHit.tres index 9cabfd7..d36ddeb 100644 --- a/GameModes/DoNotGetHit.tres +++ b/GameModes/DoNotGetHit.tres @@ -10,6 +10,7 @@ win_conditions = 0 survival_time = 160.0 max_number_of_chests = 3 money_lost_multiplier = 0.5 +die_on_leaving_bounds = true weapon_penalty = 0 weapon_drop_percentage = 0.5 ammo_drop_percentage = 0.5 diff --git a/GameModes/standard_stam_regen.tres b/GameModes/standard_stam_regen.tres index 8aff47c..ac89356 100644 --- a/GameModes/standard_stam_regen.tres +++ b/GameModes/standard_stam_regen.tres @@ -10,6 +10,7 @@ win_conditions = 0 survival_time = 160.0 max_number_of_chests = 3 money_lost_multiplier = 0.5 +die_on_leaving_bounds = true weapon_penalty = 0 weapon_drop_percentage = 0.5 ammo_drop_percentage = 0.5 diff --git a/Tools/playlist_generator.tscn b/Tools/playlist_generator.tscn index 5026b9d..dcb65ab 100644 --- a/Tools/playlist_generator.tscn +++ b/Tools/playlist_generator.tscn @@ -40,6 +40,5 @@ script = ExtResource("1_qvqs2") maps_in_rotation = Array[ExtResource("2_3l62y")]([SubResource("Resource_3w5k4"), SubResource("Resource_t5q6w"), SubResource("Resource_2pkld"), SubResource("Resource_13n7k")]) gamemodes_in_rotation = Array[ExtResource("2_hoyqc")]([ExtResource("2_85uje"), ExtResource("3_t0mxh"), ExtResource("4_8wht4"), ExtResource("6_vu1w7")]) chest_drops = Array[Resource]([ExtResource("8_hewbh")]) -chests_per_match = null [connection signal="gui_input" from="." to="." method="_on_gui_input"] diff --git a/assets/LevelBlockouts/hub_1.tscn b/assets/LevelBlockouts/hub_1.tscn index 3c6d817..1035b10 100644 --- a/assets/LevelBlockouts/hub_1.tscn +++ b/assets/LevelBlockouts/hub_1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://otkecr0hcyon"] +[gd_scene load_steps=18 format=3 uid="uid://otkecr0hcyon"] [ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="1_48lr2"] [ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="1_ibypk"] @@ -10,6 +10,7 @@ [ext_resource type="PackedScene" uid="uid://c0uv33kbndbvy" path="res://assets/trashcan.tscn" id="8_7e18o"] [ext_resource type="PackedScene" uid="uid://dyu46bns8mesv" path="res://assets/mac10_pickup.tscn" id="9_7e18o"] [ext_resource type="PackedScene" uid="uid://dugcxo2665me0" path="res://assets/revolver1_pickup.tscn" id="10_20m5p"] +[ext_resource type="PackedScene" uid="uid://dgapcuvg0gtmm" path="res://assets/scene_changer.tscn" id="11_titu4"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_48lr2"] sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1) @@ -237,3 +238,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.1056, 3.01416, -13.8355) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19.6736, 6.57787, -17.6494) [node name="Tubes" type="Node3D" parent="."] + +[node name="Scene Changer" parent="Tubes" instance=ExtResource("11_titu4")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.07024, -64.2195, -11.6417) diff --git a/assets/scene_changer.tscn b/assets/scene_changer.tscn index f46a1f7..d803c44 100644 --- a/assets/scene_changer.tscn +++ b/assets/scene_changer.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" uid="uid://euykrpkb4h0m" path="res://scripts/scene_changer.gd" id="1_7ngxb"] [sub_resource type="SphereShape3D" id="SphereShape3D_idsnf"] -radius = 5.0 +radius = 4.0 [sub_resource type="SphereMesh" id="SphereMesh_wfy04"] diff --git a/scripts/HelperFuncs.gd b/scripts/HelperFuncs.gd index 723b0a5..48540f1 100644 --- a/scripts/HelperFuncs.gd +++ b/scripts/HelperFuncs.gd @@ -32,15 +32,9 @@ func weighted_random(choices): sum_of_choices += choices[i] var random_number = randf_range(0,sum_of_choices) - print("----------------------------------------------------------------") - print("CHOICES: ",choices) - print("SUM OF CHOICES: ",sum_of_choices) - print("RANDOM NUMBER: ",random_number) for i in choices: if random_number < choices[i]: - print("SELECTION: ", i) - print("----------------------------------------------------------------") return i random_number -= choices[i] @@ -54,37 +48,21 @@ func only_valid_chars(input_string: String) -> String: return valid_chars func checksum(check_data): - var mult = 0.0 - var div : float = 0.0 - var checksum : float = 0.0 - var index = 0.0 + var checksum_array = [] + + #hash all passed-in data and add to new array for data in check_data: - #get value from names - if data is String: - var stringnumber = 0 - var letter_index = 0 - for char in data: - if char.is_valid_identifier(): - if letter_to_number.has(char.to_upper()): - stringnumber += letter_to_number[char.to_upper()] - - letter_index += 1 - - print("stringnumber : ",stringnumber) - data = stringnumber + letter_index - - if data == null or data ==0: - data = TAU - if data > div: - div = data - if index == 0: - mult = PI * data - checksum += mult * data - mult = PI * data - print("DATA : ",data," | MULT : ",mult) - index += 1 + var hashed_data = hash(data) + checksum_array.append(hashed_data) - checksum = checksum/div - print(checksum) - return checksum + #add together + var checksum_final = 0 + for num in checksum_array: + if num is int: + checksum_final += num + + #finally, re-hash + checksum_final = hash(checksum_final) + + return checksum_final diff --git a/scripts/playlist_generator.gd b/scripts/playlist_generator.gd index cdd8292..100b0bb 100644 --- a/scripts/playlist_generator.gd +++ b/scripts/playlist_generator.gd @@ -44,13 +44,20 @@ func generate_playlist() -> void: chests.append(chest_details) chest_serial_no += 1 - var match_details = {"round" : round,"chests" : chests} + var numbers = [] + for i in range(chests_per_match): + numbers.append(i+1) + + numbers.shuffle() + + var match_details = {"round" : round,"chests" : chests,"chest_order" : numbers} matches.append(match_details) playlist.append(matches) print(playlist[0][0]["round"][0]) print(playlist[0][0]["chests"][3]) + print(playlist[0][0]["chest_order"]) GameGlobals.playlist = playlist func only_valid_chars(input_string: String) -> String: diff --git a/scripts/weapon_uberscript.gd b/scripts/weapon_uberscript.gd index 83d13f5..aae333e 100644 --- a/scripts/weapon_uberscript.gd +++ b/scripts/weapon_uberscript.gd @@ -326,7 +326,6 @@ func mark_anim_rot(): var time = anim_player.current_animation_position var rot = anim_rot_body.rotation var pos = anim_rot_body.position - print("MARK STATS : ",{"time" : time,"rot" : rot,"pos" : pos}) spawn_av_lv.append({"time" : time,"rot" : rot,"pos" : pos}) func solve_anim_av_lv():