-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbeta_data.gd
More file actions
310 lines (271 loc) · 10 KB
/
beta_data.gd
File metadata and controls
310 lines (271 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
extends Node
# Game data manager
const config_path = "./config.json"
var overlay: Overlay
var screen_recorder: ScreenRecorder
var menu: GameMenu
var time_last_detection = 0
var sec_between_detection = 0.5
var current_screen_score_diff = 0.0
var is_warning = false
var duration_without_detections = 0.0
var is_eco_active = false
const score_next_lvl = 2000
const full_screen_glitched_scn = preload("res://GameMode/full_screen_glitched.tscn")
const TEXT_CENSOR_BOX = preload("res://BoxExamples/text_censor_box.tscn")
const SUBLIM_MESSAGE_BOX = preload("res://BoxExamples/sublim_message_box.tscn")
const GLITCHED_BOX = preload("res://BoxExamples/glitched_box.tscn")
const CUSTOM_TEXTURE_CENSOR_BOX = preload("res://BoxExamples/custom_texture_censor_box.tscn")
const BASE_CENSOR_BOX = preload("res://BoxExamples/base_censor_box.tscn")
var box_scn_types = [BASE_CENSOR_BOX, GLITCHED_BOX, SUBLIM_MESSAGE_BOX,
TEXT_CENSOR_BOX, CUSTOM_TEXTURE_CENSOR_BOX,
]
var custom_texture: ImageTexture = null
const FULL_SCREEN_TEXT_CREATOR = preload("res://BoxExamples/full_screen_text_creator.tscn")
var current_fullscreen_text_texture_creator: FSTextCreator = null
const _labels = [
"FEMALE_GENITALIA_COVERED",
"FEMALE_GENITALIA_EXPOSED",
"ANUS_COVERED",
"ANUS_EXPOSED",
"BUTTOCKS_COVERED",
"BUTTOCKS_EXPOSED",
"FEMALE_BREAST_COVERED",
"FEMALE_BREAST_EXPOSED",
"FEET_COVERED",
"FEET_EXPOSED",
"BELLY_COVERED", # not used
"BELLY_EXPOSED",
"ARMPITS_COVERED", # not used
"ARMPITS_EXPOSED",
"FACE_FEMALE",
"FACE_MALE",
"MALE_BREAST_EXPOSED",
"MALE_GENITALIA_EXPOSED",
]
const gd := {
score = 1,
audio = true,
lvl = 0,
game_mode = true,
hud_visible = true,
hud_x = 0,
hud_y = 0,
hud_scale = 1,
fs_text_censor = "Beta Keep Out ",
cd_detections = 0.1,
eco_detections = false,
cd_comments = 20,
custom_censors = 0,
custom_censor_mask = int(1),
custom_texture = "./fox.png",
fps_screen_recorder = 30,
xp_multiplier = 1.0,
# this is just a const copy to get names of game_data keys
}
# lua style dict to store config in json
# can access with game_data.score or game_data["score"]
var game_data := {
score = 1,
audio = true,
lvl = 0,
game_mode = true,
hud_visible = true,
hud_x = 0,
hud_y = 0,
hud_scale = 1,
fs_text_censor = "Beta Keep Out ",
cd_detections = 0.1,
eco_detections = false,
cd_comments = 20,
custom_censors = 0,
custom_censor_mask = int(1),
custom_texture = "./fox.png",
fps_screen_recorder = 30,
xp_multiplier = 1.0,
#never change old data name to avoid breaking old saves
}
func _ready():
overlay = get_node("/root/Overlay")
screen_recorder = get_node("/root/Overlay/ScreenRecorder")
var is_existing_save = load_config_json()
apply_new_config(is_existing_save)
func _exit_tree():
save_config_json()
func load_config_json():
if not FileAccess.file_exists(config_path):
print("No config file. Creating a new save...")
return false
var file = FileAccess.open(config_path, FileAccess.READ)
var saved_data: Dictionary = JSON.parse_string(file.get_as_text())
file.close()
for key in game_data.keys():
var saved_value = saved_data.get(key)
if saved_value != null: game_data[key] = saved_value
game_data.lvl = int(game_data.lvl)
game_data.custom_censors = int(game_data.custom_censors)
game_data.custom_censor_mask = int(game_data.custom_censor_mask)
game_data.fps_screen_recorder = int(game_data.fps_screen_recorder)
return true
func apply_new_config(is_existing_save):
# most of nodes are not ready at this time
# lots of config is done in menu::apply_menu_config()
await get_tree().process_frame
new_fullscreen_text_texture(game_data.fs_text_censor)
if game_data.game_mode:
if not is_existing_save:
overlay.beta_voices.get_node("intro").play()
await get_tree().create_timer(3.5).timeout
make_screen_glitched()
func save_config_json():
# this will erase the previous config
var file = FileAccess.open(config_path, FileAccess.WRITE)
file.store_string(JSON.stringify(game_data))
file.close()
func censor_type_of_part(body_part : String, score : float):
var bp = body_part
var is_low_face_male = (bp=="FACE_MALE" and score < 0.4) # face male is very imprecise
var is_high_face_male = (bp=="FACE_MALE" and not is_low_face_male)
var porn_fema = (bp=="ANUS_EXPOSED" or bp=="FEMALE_GENITALIA_EXPOSED" or bp=="FEMALE_BREAST_EXPOSED")
var sexy_fem = (bp=="ANUS_COVERED" or bp=="FEMALE_GENITALIA_COVERED" or bp=="BUTTOCKS_EXPOSED")
var beauty_fem = (is_low_face_male or bp=="FACE_FEMALE" or bp=="BUTTOCKS_COVERED" or bp == "FEMALE_BREAST_COVERED")
var beta_fem = (bp=="FEET_EXPOSED" or bp=="FEET_COVERED" or bp=="ARMPITS_EXPOSED" or bp=="BELLY_EXPOSED")
var male = (is_high_face_male or bp=="MALE_BREAST_EXPOSED" or bp=="MALE_GENITALIA_EXPOSED")
if porn_fema: return 0
if sexy_fem: return 1
if beauty_fem: return 2
if beta_fem: return 3
if male: return 4
return -1
func new_detections(detections):
var current_time_detection = Time.get_ticks_msec()
self.sec_between_detection = (current_time_detection - time_last_detection) / 1000.0
#print(int(1.0/sec_between_detection + 0.5), " detec/sec")
self.time_last_detection = current_time_detection
var detections_array = JSON.parse_string(detections)
overlay.beta_voices.comment_detections(detections_array)
check_eco_mode(detections_array)
current_screen_score_diff = 0
if not game_data.game_mode:
return
if len(detections_array) == 0:
current_screen_score_diff = -0.7
for d in detections_array:
var d_class = d["class"]
var d_score = d["score"]
var d_box = d["box"]
current_screen_score_diff += update_score_from_detection(d_class, d_score, d_box)
add_score(current_screen_score_diff)
func update_score_from_detection(d_class, d_score, d_box):
var box_area = d_box[2] * d_box[3]
var censor_type = censor_type_of_part(d_class, d_score)
var area_coeff = clamp(15.0*box_area/overlay.screen_area, 0.5, 1.5)
const type_to_score = {0: 10.0, 1: 6.0, 2: 3.0, 3: 1.5, 4: -4.0, -1: 0.0}
var score_diff = area_coeff * type_to_score[censor_type]
return score_diff
func add_score(score_diff):
game_data.score += score_diff * game_data.xp_multiplier * sec_between_detection
if game_data.score > BetaData.get_score_next_lvl():
trigger_warning()
return
if game_data.score < -BetaData.get_score_next_lvl():
trigger_lower_lvl()
return
func trigger_warning():
if is_warning:
return
is_warning = true
overlay.warning_message.start_count_down()
func trigger_harder_lvl():
game_data.score = 1
game_data.lvl = min(3, game_data.lvl+1)
make_screen_glitched()
await get_tree().create_timer(1).timeout
overlay.beta_voices.get_node("lvl"+str(int(game_data.lvl))).play()
func trigger_lower_lvl():
game_data.score = 1
game_data.lvl = max(-1, game_data.lvl-1)
overlay.beta_voices.get_node("lowerlvl").play()
func make_screen_glitched():
overlay.add_child(full_screen_glitched_scn.instantiate())
func set_game_mode(is_game_mode):
game_data.game_mode = is_game_mode
overlay.overlay_hud.visible = is_game_mode and game_data.hud_visible
if is_game_mode and abs(game_data.score) > 0.5:
make_screen_glitched()
func must_censor_detection(detection):
# not used
if not game_data.game_mode:
# use custom censor settings
return false
var censor_type = censor_type_of_part(detection["class"], detection["score"])
if censor_type == 4 or censor_type == -1:
return false
return censor_type <= game_data.lvl
func get_censor_scn_for_detection(detection):
if not game_data.game_mode:
# use custom censor settings
return TEXT_CENSOR_BOX
# porn_fema: 0, sexy_fem: 1, beauty_fem: 2, beta_fem: 3
var lvl0 = {0: GLITCHED_BOX, 1: SUBLIM_MESSAGE_BOX, 2: SUBLIM_MESSAGE_BOX if randf()<0.2 else null, 3: null}
const lvl1 = {0: TEXT_CENSOR_BOX, 1: GLITCHED_BOX, 2: SUBLIM_MESSAGE_BOX, 3: null}
const lvl2 = {0: TEXT_CENSOR_BOX, 1: TEXT_CENSOR_BOX, 2: GLITCHED_BOX, 3: null}
const lvl3 = {0: TEXT_CENSOR_BOX, 1: TEXT_CENSOR_BOX, 2: GLITCHED_BOX, 3: SUBLIM_MESSAGE_BOX}
var censor_lvls = [lvl0, lvl1, lvl2, lvl3]
var censor_type = censor_type_of_part(detection["class"], detection["score"])
if game_data.lvl == -1:
return null
#if censor_type == 4 or censor_type == -1:
#return null
var censor_lvl: Dictionary = censor_lvls[game_data.lvl]
return censor_lvl.get(censor_type)
func update_warning(is_no_detection):
if not is_no_detection:
overlay.warning_message.total_sec_with_no_detection = 0
else:
overlay.warning_message.total_sec_with_no_detection += sec_between_detection
if overlay.warning_message.total_sec_with_no_detection > 1.1:
overlay.warning_message.play_success()
overlay.warning_message.stop()
game_data.score = game_data.score / 2.0
func new_fullscreen_text_texture(new_text: String):
if current_fullscreen_text_texture_creator != null:
current_fullscreen_text_texture_creator.queue_free()
current_fullscreen_text_texture_creator = FULL_SCREEN_TEXT_CREATOR.instantiate()
current_fullscreen_text_texture_creator.set_size_and_text(overlay.screen_size, new_text)
overlay.add_child(current_fullscreen_text_texture_creator)
func update_fullscreen_text_texture_material(new_texture):
TEXT_CENSOR_BOX.instantiate().get_child(0).material.set_shader_parameter("fs_text_texture", new_texture)
func check_eco_mode(detections_array):
if is_eco_active:
if len(detections_array) > 0:
overlay.tcp_listner.restart_detector(game_data.cd_detections)
is_eco_active = false
return
# is_eco_active == false
if not game_data.eco_detections:
return
if len(detections_array) > 0:
duration_without_detections = 0
return
duration_without_detections += sec_between_detection
if duration_without_detections > 10:
overlay.tcp_listner.restart_detector(5)
is_eco_active = true
func get_score_next_lvl():
return score_next_lvl * (1 + abs(game_data.lvl))
func rescale_detection(detection, sx, sy):
sx = clamp(sx, 0.01, 100)
sy = clamp(sy, 0.01, 100)
var new_size_x = sx * detection["box"][2]
var new_size_y = sy * detection["box"][3]
var new_box = [
detection["box"][0] - new_size_x*(1.0/sx - 1)/2,
detection["box"][1] - new_size_y*(1.0/sy - 1)/2,
new_size_x,
new_size_y,
]
detection["box"] = new_box
func get_custom_censor_scn_for_detection(detection):
# not used
return game_data.custom_censors.get(detection["class"])