balancing mit W

This commit is contained in:
Mikhail Aristov 2024-01-28 14:45:47 +01:00
parent d021fff64b
commit 1ffe5c688c
5 changed files with 48 additions and 49 deletions

View File

@ -1,6 +1,16 @@
class_name AudienceProfile class_name AudienceProfile
extends Node2D extends Node2D
const HAPPY_THRESHOLD: float = 2
const ANGRY_THRESHOLD: float = -1
const LASHOUT_THRESHOLD: float = -5
const HAPPINESS_DECAY: float = .01
const LASHOUT_DECAY: float = .01
const GOOD_REACTION: float = 1
const NEUTRAL_REACTION: float = .1
const BAD_REACTION: float = -1.2
const BOTTLE_REACTION: float = 3
class ProfileData: class ProfileData:
var happy_threshold: float var happy_threshold: float
@ -39,23 +49,12 @@ var joke_mood_mapping: Dictionary
static func get_profile_data(index) -> ProfileData: static func get_profile_data(index) -> ProfileData:
var profiles = [ var profiles = [
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 1, 1: -0.25, 2: 0, 3: 2}), ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: GOOD_REACTION, 1: BAD_REACTION, 2: NEUTRAL_REACTION, 3: BOTTLE_REACTION}),
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 0, 1: 1, 2: -0.25, 3: 2}), ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: NEUTRAL_REACTION, 1: GOOD_REACTION, 2: BAD_REACTION, 3: BOTTLE_REACTION}),
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: -0.25, 1: 0, 2: 1, 3: 2}), ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: BAD_REACTION, 1: NEUTRAL_REACTION, 2: GOOD_REACTION, 3: BOTTLE_REACTION}),
] ]
return profiles[index] return profiles[index]
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func load_data(data: ProfileData): func load_data(data: ProfileData):
happy_threshold = data.happy_threshold happy_threshold = data.happy_threshold
angry_threshold = data.angry_threshold angry_threshold = data.angry_threshold

View File

@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://scenes/crowd/crowd.gd" id="1_y7wyj"] [ext_resource type="Script" path="res://scenes/crowd/crowd.gd" id="1_y7wyj"]
[ext_resource type="Texture2D" uid="uid://b6p145ne8x013" path="res://sprites/room/table.svg" id="2_bax5s"] [ext_resource type="Texture2D" uid="uid://b6p145ne8x013" path="res://sprites/room/table.svg" id="2_bax5s"]
[ext_resource type="PackedScene" path="res://sprites/room/chair.tscn" id="3_y4hpm"] [ext_resource type="PackedScene" uid="uid://bbehbuw5lvfkr" path="res://sprites/room/chair.tscn" id="3_y4hpm"]
[node name="Crowd" type="Node2D"] [node name="Crowd" type="Node2D"]
position = Vector2(240, 232) position = Vector2(240, 232)

View File

@ -83,7 +83,7 @@ func _process(delta):
if laughter_left >= 0: if laughter_left >= 0:
laughter_left -= delta laughter_left -= delta
if not is_listening and mood > profile.happy_threshold * .5: if not is_listening and mood > profile.happy_threshold * .9:
mood -= profile.happiness_decay * delta mood -= profile.happiness_decay * delta
elif not is_listening and mood < profile.lashout_threshold * .9: elif not is_listening and mood < profile.lashout_threshold * .9:
mood += profile.lashout_decay * delta mood += profile.lashout_decay * delta
@ -103,7 +103,7 @@ func _input(event):
update_mood(-1.) update_mood(-1.)
func update_mood(change: float): func update_mood(change: float):
if mood > profile.happy_threshold and change > 0 and laughter_left <= 0: if laughter_left <= 0 and change > 0 and (mood + change) > profile.happy_threshold :
laughter_left = laughter_duration laughter_left = laughter_duration
# bob head # bob head
var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs) var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs)
@ -143,8 +143,8 @@ func on_joke_start():
func on_hear_joke(joke: Joke): func on_hear_joke(joke: Joke):
var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness
if joke.type == last_joke_heard: if joke.type == last_joke_heard and mood_change > 0:
mood_change = min(0, mood_change) mood_change *= .5
update_mood(mood_change) update_mood(mood_change)
last_joke_heard = joke.type last_joke_heard = joke.type
@ -152,7 +152,7 @@ func on_joke_finish():
is_listening = false is_listening = false
func throw_bottle(): func throw_bottle():
mood += 2.0 mood = profile.lashout_threshold * 0.99
var bottle_scene = preload("res://scenes/objects/bottle.tscn") var bottle_scene = preload("res://scenes/objects/bottle.tscn")
var bottle = bottle_scene.instantiate() var bottle = bottle_scene.instantiate()

View File

@ -19,7 +19,7 @@ var required_stamina: int
var effectiveness: float var effectiveness: float
static func get_bottle_joke(): static func get_bottle_joke():
return Joke.new(JokeType.Bottle, 5, 1) return Joke.new(JokeType.Bottle, 15, 1)
static func get_random_joke(type): static func get_random_joke(type):
var stamina = STAMINA_CATEGORIES[randi_range(0, STAMINA_CATEGORIES.size() - 1)] var stamina = STAMINA_CATEGORIES[randi_range(0, STAMINA_CATEGORIES.size() - 1)]

File diff suppressed because one or more lines are too long