<commit_before>var bag

var hp
var max_hp

var hit_protection = false
var is_invulnerable = false
var invulnerability_period = 0.5

var avatar
var is_processing = false
var initial_position = Vector2(0, 0)
var score = 100

var sounds = {
    'attack' : null,
    'die' : null,
    'hit' : null,
}

func _init(bag):
    self.bag = bag
    self.max_hp = 5
    self.hp = 5


func get_hp():
    return self.hp

func set_hp(hp):
    if hp <= 0:
        self.die()
    else:
        if hp <= self.max_hp:
            self.hp = hp
        else:
            self.hp = self.max_hp

func get_pos():
    return self.avatar.get_pos()

func get_screen_pos():
    var position = self.get_pos()
    var global_x = position.x / self.bag.camera.zoom.x
    var global_y = position.y / self.bag.camera.zoom.y
    return Vector2(global_x, global_y)

func spawn(position):
    self.attach()
    self.initial_position = position
    self.avatar.set_pos(self.initial_position)

func despawn():
    self.detach()

func attach():
    self.is_processing = true
    self.bag.action_controller.attach_object(self.avatar)

func detach():
    self.is_processing = false
    self.bag.action_controller.detach_object(self.avatar)<commit_msg>Made sure, that dying enemies have their hp set to zero<commit_after>var bag

var hp
var max_hp

var hit_protection = false
var is_invulnerable = false
var invulnerability_period = 0.5

var avatar
var is_processing = false
var initial_position = Vector2(0, 0)
var score = 100

var sounds = {
    'attack' : null,
    'die' : null,
    'hit' : null,
}

func _init(bag):
    self.bag = bag
    self.max_hp = 5
    self.hp = 5


func get_hp():
    return self.hp

func set_hp(hp):
    if hp <= 0:
        self.hp = 0
        self.die()
    else:
        if hp <= self.max_hp:
            self.hp = hp
        else:
            self.hp = self.max_hp

func get_pos():
    return self.avatar.get_pos()

func get_screen_pos():
    var position = self.get_pos()
    var global_x = position.x / self.bag.camera.zoom.x
    var global_y = position.y / self.bag.camera.zoom.y
    return Vector2(global_x, global_y)

func spawn(position):
    self.attach()
    self.initial_position = position
    self.avatar.set_pos(self.initial_position)

func despawn():
    self.detach()

func attach():
    self.is_processing = true
    self.bag.action_controller.attach_object(self.avatar)

func detach():
    self.is_processing = false
    self.bag.action_controller.detach_object(self.avatar)
{'fraction_non_alphanumeric': 0.10846774193548388, 'fraction_numerical': 0.010080645161290322, 'mean_word_length': 2.764795144157815, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '870587', 'n_tokens_mistral': 906, 'n_tokens_neox': 878, 'n_words': 213}