Compare commits
24 Commits
76cb23b5db
...
master
Author | SHA1 | Date | |
---|---|---|---|
356897045f | |||
1e1f8cebe8
|
|||
b21ad67cfc
|
|||
4fffa8784a
|
|||
dc3f8c94f8 | |||
f06bf17757
|
|||
d74831df56
|
|||
2bd83504f2
|
|||
3f21aef4eb
|
|||
6fff2dd9a3
|
|||
0dada63709
|
|||
d862974747
|
|||
f53d91a9eb
|
|||
d57a59e9fe
|
|||
950d177936
|
|||
40d6162b95
|
|||
7311b52fad
|
|||
b2129d9aa6
|
|||
892b37572f
|
|||
7aedea8206
|
|||
7cff7b62e9
|
|||
0d8356957d
|
|||
9044338662
|
|||
0d8846fb83
|
16
.github/workflows/flake-check.yaml
vendored
Normal file
16
.github/workflows/flake-check.yaml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: flake-check
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: [ ubuntu-latest, homelab ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- run: nix flake check
|
||||
|
9
assets/shaders/base_color_tint.gdshader
Normal file
9
assets/shaders/base_color_tint.gdshader
Normal file
@@ -0,0 +1,9 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform vec4 base_color : source_color = vec4(1.0, 0.2, 0.2, 1.0); // tint color
|
||||
|
||||
void fragment() {
|
||||
vec4 tex = texture(TEXTURE, UV);
|
||||
|
||||
COLOR = vec4(base_color.rgb * tex.r, tex.a);
|
||||
}
|
1
assets/shaders/base_color_tint.gdshader.uid
Normal file
1
assets/shaders/base_color_tint.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cf48pgfl308o3
|
@@ -3,19 +3,28 @@ uniform vec4 water_color : source_color = vec4(0.0, 0.0, 1.0, 1.0);
|
||||
uniform sampler2D noise_tex; // noise texture
|
||||
uniform vec2 noise_speed = vec2(0.05, 0.01);
|
||||
uniform float noise_strength = 0.2; // how much to lighten/darken
|
||||
uniform float pixel_size = 0.005;
|
||||
|
||||
void fragment() {
|
||||
vec2 uv = UV;
|
||||
vec4 base_tex = texture(TEXTURE, uv);
|
||||
float is_water = step(0.8, 1.0 - distance(base_tex.rgb, water_color.rgb));
|
||||
|
||||
vec2 snapped_uv = floor(SCREEN_UV / pixel_size) * pixel_size;
|
||||
// Scroll UVs for noise animation
|
||||
vec2 noise_uv = SCREEN_UV + noise_speed * TIME;
|
||||
//vec2 noise_uv = SCREEN_UV + noise_speed * TIME;
|
||||
vec2 noise_uv = snapped_uv + noise_speed * TIME;
|
||||
vec4 noise_sample = texture(noise_tex, fract(noise_uv));
|
||||
|
||||
float n = noise_sample.r;
|
||||
n = pow(n, 3.0) * 4.0;
|
||||
n = clamp(n,0.0, 1.0);
|
||||
|
||||
vec4 noisy_color = water_color.rgba;
|
||||
noisy_color += vec4(0.1* (noise_sample.r - 0.5), 0.05 * (noise_sample.r - 0.5), 0.0, 1.0);
|
||||
// Use noise (0..1) to brighten/darken the water color
|
||||
float brightness = (noise_sample.r - 0.5) * 2.0 * noise_strength;
|
||||
vec4 animated_water = water_color + vec4(vec3(brightness), 0.0);
|
||||
float brightness = (n - 0.5) * 4.0 * noise_strength;
|
||||
vec4 animated_water = noisy_color + vec4(vec3(brightness), 0.0);
|
||||
|
||||
|
||||
COLOR = mix(base_tex, animated_water, is_water);
|
||||
|
BIN
assets/sprites/puddle_1.aseprite
(Stored with Git LFS)
Normal file
BIN
assets/sprites/puddle_1.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/sprites/puddle_1.png
(Stored with Git LFS)
Normal file
BIN
assets/sprites/puddle_1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/sprites/puddle_1.png.import
Normal file
34
assets/sprites/puddle_1.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c5t4it4if0s6g"
|
||||
path="res://.godot/imported/puddle_1.png-28d62b8b3cc5647c5219303699bcce62.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/puddle_1.png"
|
||||
dest_files=["res://.godot/imported/puddle_1.png-28d62b8b3cc5647c5219303699bcce62.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
assets/sprites/slime_small grayscale.aseprite
(Stored with Git LFS)
Normal file
BIN
assets/sprites/slime_small grayscale.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/sprites/slime_small grayscale.png
(Stored with Git LFS)
Normal file
BIN
assets/sprites/slime_small grayscale.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/sprites/slime_small grayscale.png.import
Normal file
34
assets/sprites/slime_small grayscale.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ctob5me7woid8"
|
||||
path="res://.godot/imported/slime_small grayscale.png-b5ea2536903e774dce2837ff19f6ad76.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/slime_small grayscale.png"
|
||||
dest_files=["res://.godot/imported/slime_small grayscale.png-b5ea2536903e774dce2837ff19f6ad76.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
assets/sprites/slime_small.aseprite
(Stored with Git LFS)
Normal file
BIN
assets/sprites/slime_small.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/sprites/slime_small.png
(Stored with Git LFS)
Normal file
BIN
assets/sprites/slime_small.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/sprites/slime_small.png.import
Normal file
34
assets/sprites/slime_small.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bfj2h2jp1w60p"
|
||||
path="res://.godot/imported/slime_small.png-a01d407ba84c2dd70ce8b2ef5c142cae.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/slime_small.png"
|
||||
dest_files=["res://.godot/imported/slime_small.png-a01d407ba84c2dd70ce8b2ef5c142cae.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
assets/sprites/small_bleed_icon.aseprite
(Stored with Git LFS)
Normal file
BIN
assets/sprites/small_bleed_icon.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/sprites/small_bleed_icon.png
(Stored with Git LFS)
Normal file
BIN
assets/sprites/small_bleed_icon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
assets/sprites/small_bleed_icon.png.import
Normal file
34
assets/sprites/small_bleed_icon.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c856sh6vk5lqa"
|
||||
path="res://.godot/imported/small_bleed_icon.png-472f2c7cb608bb835a947b6c2d78acf7.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/small_bleed_icon.png"
|
||||
dest_files=["res://.godot/imported/small_bleed_icon.png-472f2c7cb608bb835a947b6c2d78acf7.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
@@ -3,7 +3,7 @@
|
||||
name="Linux"
|
||||
platform="Linux"
|
||||
runnable=true
|
||||
advanced_options=false
|
||||
advanced_options=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
|
27
flake.nix
27
flake.nix
@@ -46,6 +46,30 @@
|
||||
}
|
||||
);
|
||||
|
||||
checks = forAllSystems (
|
||||
{ pkgs }:
|
||||
{
|
||||
gdformat = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "gdformat-check";
|
||||
src = pkgs.lib.sources.sourceFilesBySuffices (pkgs.lib.cleanSource ./.) [ ".gd" ];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gdtoolkit_4
|
||||
];
|
||||
|
||||
dontBuild = true;
|
||||
doCheck = true;
|
||||
|
||||
checkPhase = ''
|
||||
export HOME=$(mktemp -d)
|
||||
find . -name "*.gd" -print0 | xargs -0 gdformat --check
|
||||
echo "All .gd files are properly formatted"
|
||||
'';
|
||||
installPhase = "mkdir $out";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
packages = forAllSystems (
|
||||
{ pkgs }:
|
||||
let
|
||||
@@ -77,7 +101,6 @@
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
find .
|
||||
install -D -m 755 -t $out/libexec ./build/slopvivors
|
||||
install -D -m 644 -t $out/libexec ./build/slopvivors.pck
|
||||
install -d -m 755 $out/bin
|
||||
@@ -158,7 +181,7 @@
|
||||
'';
|
||||
};
|
||||
slopvivors_docker = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "slopvivors-docker-${version}";
|
||||
name = "slopvivors-docker";
|
||||
tag = version;
|
||||
created = "now";
|
||||
contents = [
|
||||
|
@@ -24,7 +24,7 @@ const GROUP_XP_ORB = "xp_orb"
|
||||
const GROUP_PICKUP = "pickup"
|
||||
const GROUP_PROJ_MANAGER = "proj_manager"
|
||||
|
||||
enum ModRarity { LEGENDARY, EPIC, RARE, NORMAL }
|
||||
enum Rarity { LEGENDARY, EPIC, RARE, NORMAL }
|
||||
|
||||
const placeholder_tex = preload("res://assets/sprites/64x64_placeholder.tres")
|
||||
|
||||
@@ -32,7 +32,7 @@ var MOD_CHOICES = [
|
||||
{
|
||||
"internal_name": "flat_health_small",
|
||||
"name": "+10 Health",
|
||||
"rarity": ModRarity.NORMAL,
|
||||
"rarity": Rarity.NORMAL,
|
||||
"tex": placeholder_tex,
|
||||
"description": "Adds 10 flat health.",
|
||||
"weight": 100,
|
||||
@@ -43,7 +43,7 @@ var MOD_CHOICES = [
|
||||
{
|
||||
"internal_name": "flat_health_med",
|
||||
"name": "+25 Health",
|
||||
"rarity": ModRarity.RARE,
|
||||
"rarity": Rarity.RARE,
|
||||
"tex": placeholder_tex,
|
||||
"description": "Adds 25 flat health.",
|
||||
"weight": 50,
|
||||
@@ -54,7 +54,7 @@ var MOD_CHOICES = [
|
||||
{
|
||||
"internal_name": "flat_health_large",
|
||||
"name": "+50 Health",
|
||||
"rarity": ModRarity.EPIC,
|
||||
"rarity": Rarity.EPIC,
|
||||
"tex": placeholder_tex,
|
||||
"description": "Adds 50 flat health.",
|
||||
"weight": 10,
|
||||
@@ -65,7 +65,7 @@ var MOD_CHOICES = [
|
||||
{
|
||||
"internal_name": "flat_crit_small",
|
||||
"name": "2.5% More Critical Chance",
|
||||
"rarity": ModRarity.RARE,
|
||||
"rarity": Rarity.RARE,
|
||||
"tex": placeholder_tex,
|
||||
"description": "Gives 2.5% more base critical hit chance",
|
||||
"weight": 50,
|
||||
@@ -76,7 +76,7 @@ var MOD_CHOICES = [
|
||||
{
|
||||
"internal_name": "flat_crit_large",
|
||||
"name": "5% More Critical Chance",
|
||||
"rarity": ModRarity.EPIC,
|
||||
"rarity": Rarity.EPIC,
|
||||
"tex": placeholder_tex,
|
||||
"description": "Gives 5% more base critical hit chance",
|
||||
"weight": 10,
|
||||
@@ -87,6 +87,17 @@ var MOD_CHOICES = [
|
||||
]
|
||||
|
||||
|
||||
func rarity_to_color(rarity: Rarity) -> Color:
|
||||
match rarity:
|
||||
Rarity.RARE:
|
||||
return Color.YELLOW
|
||||
Rarity.EPIC:
|
||||
return Color.BLUE_VIOLET
|
||||
Rarity.LEGENDARY:
|
||||
return Color.DARK_ORANGE
|
||||
return Color.WHITE
|
||||
|
||||
|
||||
func _draw_random_choice(fortune: float = 1.0) -> Dictionary:
|
||||
var total_weight: int = 0
|
||||
for choice in MOD_CHOICES:
|
||||
|
8
scenes/enemies/effects/enemy_effect_base.gd
Normal file
8
scenes/enemies/effects/enemy_effect_base.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name EnemyEffectBase
|
||||
extends Resource
|
||||
|
||||
var enemy: EnemyBase
|
||||
|
||||
|
||||
func apply(enemy: EnemyBase) -> void:
|
||||
push_error("%s does not implement apply" % self)
|
1
scenes/enemies/effects/enemy_effect_base.gd.uid
Normal file
1
scenes/enemies/effects/enemy_effect_base.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dg3yshxb4vdiu
|
33
scenes/enemies/effects/enemy_effect_bleed.gd
Normal file
33
scenes/enemies/effects/enemy_effect_bleed.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
class_name EnemyEffectBleed
|
||||
extends EnemyEffectBase
|
||||
|
||||
var damage: float
|
||||
var duration: float
|
||||
var tick_rate: float = 1.0
|
||||
|
||||
var _timer: Timer
|
||||
var _remaining_ticks: int = 5
|
||||
var _enemy: EnemyBase
|
||||
|
||||
const PUDDLE = preload("res://scenes/puddle.tscn")
|
||||
|
||||
|
||||
func _init(enemy: EnemyBase, bleed_damage: float, duration: float):
|
||||
damage = bleed_damage
|
||||
_timer = Timer.new()
|
||||
|
||||
|
||||
func apply(enemy: EnemyBase) -> void:
|
||||
enemy.effects.append(self)
|
||||
while _remaining_ticks > 0:
|
||||
enemy.take_damage(damage, false)
|
||||
_remaining_ticks -= 1
|
||||
await enemy.get_tree().create_timer(1.0, false, true, false).timeout
|
||||
var p = PUDDLE.instantiate()
|
||||
enemy.get_parent().add_child(p)
|
||||
p.global_position = enemy.global_position
|
||||
enemy.effects.erase(self)
|
||||
|
||||
|
||||
static func _is_bleeding(enemy: EnemyBase) -> bool:
|
||||
return false
|
1
scenes/enemies/effects/enemy_effect_bleed.gd.uid
Normal file
1
scenes/enemies/effects/enemy_effect_bleed.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2ptwltm211t3
|
@@ -9,9 +9,9 @@ extends CharacterBody2D
|
||||
@onready var contact_damage_cd: Timer = $ContactDamageCD
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var move_speed: float
|
||||
var health: float
|
||||
var max_health: float
|
||||
var move_speed: float = default_move_speed
|
||||
var health: float = default_max_health
|
||||
var max_health: float = default_max_health
|
||||
var god_mode: bool = false
|
||||
var is_dead: bool = false
|
||||
|
||||
|
@@ -7,6 +7,8 @@ extends CharacterBody2D
|
||||
@export var target_distance: float = 6.0
|
||||
@export var path_update_interval: float = 1.5
|
||||
@export var xp_dropped: float = 5.0
|
||||
@export var enemy_rarity: GlobalConst.Rarity = GlobalConst.Rarity.NORMAL
|
||||
var modifiers: Array[EnemyMod] = []
|
||||
|
||||
@onready var target_cast: RayCast2D = $TargetCast
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@@ -15,18 +17,41 @@ extends CharacterBody2D
|
||||
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D
|
||||
@onready var shape_cast_2d: ShapeCast2D = $ShapeCast2D
|
||||
@onready var sprite_2d: Sprite2D = $Sprite2D
|
||||
@onready var label: Label = $HBoxContainer/Label
|
||||
@onready var effect_container: HBoxContainer = $HBoxContainer/EffectContainer
|
||||
|
||||
var player: Player
|
||||
var enemy_name: String
|
||||
var target: Node2D
|
||||
var god_mode: bool = false
|
||||
var is_dead: bool = false
|
||||
var health: float
|
||||
|
||||
var effects: Array[EnemyEffectBase]
|
||||
|
||||
var _path_update_timer: float = 0.0
|
||||
var _compute_cache: KeyedCache = KeyedCache.new()
|
||||
var _effects_visible = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
health = max_health
|
||||
enemy_name = _gen_name()
|
||||
match enemy_rarity:
|
||||
GlobalConst.Rarity.NORMAL:
|
||||
label.visible = false
|
||||
GlobalConst.Rarity.RARE:
|
||||
var mods = EnemyModPool.get_random_mods(2)
|
||||
label.visible = true
|
||||
modifiers = mods
|
||||
GlobalConst.Rarity.EPIC:
|
||||
var mods = EnemyModPool.get_random_mods(4)
|
||||
label.visible = true
|
||||
modifiers = mods
|
||||
if modifiers.size() > 0:
|
||||
enemy_name += " the %s" % modifiers.pick_random().adjective
|
||||
label.add_theme_color_override("font_color", GlobalConst.rarity_to_color(enemy_rarity))
|
||||
label.text = enemy_name
|
||||
health = get_calculated("max_health")
|
||||
shape_cast_2d.shape.radius = collision_shape_2d.shape.radius
|
||||
shape_cast_2d.enabled = false
|
||||
sprite_2d.material = sprite_2d.material.duplicate()
|
||||
@@ -39,6 +64,20 @@ func _find_player():
|
||||
target = player
|
||||
|
||||
|
||||
func _gen_name() -> String:
|
||||
return "Unnamed enemy"
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
for effect in effects:
|
||||
if effect in _effects_visible:
|
||||
continue
|
||||
var effect_sprite = Sprite2D.new()
|
||||
effect_sprite.texture = preload("res://assets/sprites/small_bleed_icon.png")
|
||||
effect_container.add_child(effect_sprite)
|
||||
_effects_visible.append(effect)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if not target:
|
||||
return
|
||||
@@ -73,7 +112,7 @@ func _do_simple_movement():
|
||||
var direction = global_position.direction_to(target.global_position)
|
||||
var distance = global_position.distance_to(target.global_position)
|
||||
if distance > 4:
|
||||
velocity = direction * move_speed
|
||||
velocity = direction * get_calculated("move_speed")
|
||||
move_and_slide()
|
||||
|
||||
|
||||
@@ -91,7 +130,7 @@ func _do_nav_agent_movement():
|
||||
if shape_cast_2d.is_colliding():
|
||||
direction = direction.bounce(shape_cast_2d.get_collision_normal(0)).normalized()
|
||||
|
||||
velocity = direction * move_speed
|
||||
velocity = direction * get_calculated("move_speed")
|
||||
move_and_slide()
|
||||
|
||||
|
||||
@@ -141,7 +180,7 @@ func die():
|
||||
|
||||
func drop_xp_orb() -> void:
|
||||
var orb: XPOrb = preload("res://scenes/xp_orb.tscn").instantiate()
|
||||
orb.value = xp_dropped
|
||||
orb.value = xp_dropped * (1 + (modifiers.size() * 3))
|
||||
orb.position = position
|
||||
get_parent().call_deferred("add_child", orb)
|
||||
|
||||
@@ -149,3 +188,23 @@ func drop_xp_orb() -> void:
|
||||
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
|
||||
if is_dead:
|
||||
queue_free()
|
||||
|
||||
|
||||
func get_calculated(key: String) -> Variant:
|
||||
# set max move speed to players move speed
|
||||
var compute_func = func():
|
||||
if key == "move_speed":
|
||||
return clampf(
|
||||
EnemyMod.get_calculated(self, key),
|
||||
0,
|
||||
player.player_stats.get_final("move_speed", player.modifiers)
|
||||
)
|
||||
return EnemyMod.get_calculated(self, key)
|
||||
|
||||
return _compute_cache.get_or_compute(key, compute_func)
|
||||
|
||||
|
||||
func has_property(key: String) -> bool:
|
||||
var cache_key = "prop_%s" % key
|
||||
var compute_func = func(): return get(key) != null
|
||||
return _compute_cache.get_or_compute(key, compute_func)
|
||||
|
@@ -72,7 +72,7 @@ texture = SubResource("PlaceholderTexture2D_pkqou")
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_satqt")
|
||||
|
||||
[node name="TargetCast" type="RayCast2D" parent="." groups=["damagable", "enemy"]]
|
||||
[node name="TargetCast" type="RayCast2D" parent="."]
|
||||
enabled = false
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
@@ -90,4 +90,25 @@ wait_time = 0.5
|
||||
shape = SubResource("CircleShape2D_pkqou")
|
||||
max_results = 2
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -53.0
|
||||
offset_right = 53.0
|
||||
offset_bottom = 40.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="EffectContainer" type="HBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 9
|
||||
horizontal_alignment = 1
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
|
||||
|
@@ -1 +1,32 @@
|
||||
extends EnemyBase
|
||||
|
||||
const NAME_PREFIXES: Array[String] = [
|
||||
"Chi",
|
||||
"Sque",
|
||||
"Flit",
|
||||
"Bat",
|
||||
"Kla",
|
||||
]
|
||||
|
||||
const NAME_ROOTS: Array[String] = [
|
||||
"ter",
|
||||
"tch",
|
||||
"reek",
|
||||
"p",
|
||||
"nap",
|
||||
]
|
||||
|
||||
const NAME_SUFFIXES: Array[String] = [
|
||||
"y",
|
||||
"a",
|
||||
"et",
|
||||
"ik",
|
||||
"in",
|
||||
]
|
||||
|
||||
|
||||
func _gen_name() -> String:
|
||||
return (
|
||||
"%s%s%s"
|
||||
% [NAME_PREFIXES.pick_random(), NAME_ROOTS.pick_random(), NAME_SUFFIXES.pick_random()]
|
||||
)
|
||||
|
34
scenes/enemies/enemy_mod.gd
Normal file
34
scenes/enemies/enemy_mod.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
class_name EnemyMod
|
||||
extends Resource
|
||||
|
||||
enum ModType { ADDITIVE, MULTIPLICATIVE, ABSOLUTE, BOOL }
|
||||
|
||||
@export var mod_name: String
|
||||
@export var mod_property: String
|
||||
@export var mod_value: float
|
||||
@export var mod_value_bool: bool = false
|
||||
@export var mod_type: ModType = ModType.MULTIPLICATIVE
|
||||
|
||||
var adjective: String
|
||||
|
||||
|
||||
static func get_calculated(enemy: EnemyBase, key: String) -> Variant:
|
||||
assert(
|
||||
enemy.has_property(key),
|
||||
"tried to calculate property '%s' where base value does not exist on %s" % [key, enemy]
|
||||
)
|
||||
var base_value = enemy.get(key)
|
||||
var add = 0.0
|
||||
var mul = 1.0
|
||||
for mod in enemy.modifiers:
|
||||
if mod.mod_property == key:
|
||||
match mod.mod_type:
|
||||
ModType.ADDITIVE:
|
||||
add += mod.mod_value
|
||||
ModType.MULTIPLICATIVE:
|
||||
mul *= mod.mod_value
|
||||
ModType.ABSOLUTE:
|
||||
return mod.mod_value
|
||||
ModType.BOOL:
|
||||
return mod.mod_value_bool
|
||||
return (base_value + add) * mul
|
1
scenes/enemies/enemy_mod.gd.uid
Normal file
1
scenes/enemies/enemy_mod.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d2mvgwmsmcxp4
|
58
scenes/enemies/enemy_mod_pool.gd
Normal file
58
scenes/enemies/enemy_mod_pool.gd
Normal file
@@ -0,0 +1,58 @@
|
||||
class_name EnemyModPool
|
||||
extends Resource
|
||||
|
||||
const MAX_HEALTH_MOD: Dictionary = {
|
||||
"mod_name": "Extra health",
|
||||
"mod_property": "max_health",
|
||||
"mod_value": 1.0,
|
||||
"mod_value_bool": false,
|
||||
"mod_type": EnemyMod.ModType.MULTIPLICATIVE,
|
||||
"mod_adjectives":
|
||||
[
|
||||
"Sturdy",
|
||||
"Bulky",
|
||||
"Ironclad",
|
||||
"Unyielding",
|
||||
"Stonehide",
|
||||
"Thicc",
|
||||
"Chunky",
|
||||
"Pudgy",
|
||||
"Chonky",
|
||||
"Double-stuffed"
|
||||
],
|
||||
}
|
||||
|
||||
const MOD_POOL = [
|
||||
{
|
||||
"mod_name": "Extra movement speed",
|
||||
"mod_property": "move_speed",
|
||||
"mod_value": 1.25,
|
||||
"mod_value_bool": false,
|
||||
"mod_type": EnemyMod.ModType.MULTIPLICATIVE,
|
||||
"mod_adjectives": ["Swift", "Nimble", "Fleet", "Spry", "Skittering", "Zoomy", "Zippy"]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
static func get_random_mods(count: int) -> Array[EnemyMod]:
|
||||
var mods: Array[EnemyMod] = []
|
||||
# always include extra health mod
|
||||
var hp_mod = _dict_to_mod(MAX_HEALTH_MOD)
|
||||
hp_mod.mod_value *= 5 * count
|
||||
mods.append(hp_mod)
|
||||
for i in count:
|
||||
var mod_data = MOD_POOL.pick_random()
|
||||
var mod = _dict_to_mod(mod_data)
|
||||
mods.append(mod)
|
||||
return mods
|
||||
|
||||
|
||||
static func _dict_to_mod(d: Dictionary) -> EnemyMod:
|
||||
var mod: EnemyMod = EnemyMod.new()
|
||||
mod.mod_name = d["mod_name"]
|
||||
mod.mod_property = d["mod_property"]
|
||||
mod.mod_value = d["mod_value"]
|
||||
mod.mod_value_bool = d["mod_value_bool"]
|
||||
mod.mod_type = d["mod_type"]
|
||||
mod.adjective = d["mod_adjectives"].pick_random()
|
||||
return mod
|
1
scenes/enemies/enemy_mod_pool.gd.uid
Normal file
1
scenes/enemies/enemy_mod_pool.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bl11yfav37ecs
|
@@ -1 +1,29 @@
|
||||
extends EnemyBase
|
||||
|
||||
const NAME_PREFIXES: Array[String] = [
|
||||
"Sk",
|
||||
"Sn",
|
||||
"Gr",
|
||||
"R",
|
||||
"Kr",
|
||||
"V",
|
||||
"Vr",
|
||||
]
|
||||
|
||||
const NAME_ROOTS: Array[String] = [
|
||||
"itch",
|
||||
"abble",
|
||||
"itter",
|
||||
"usk",
|
||||
"arp",
|
||||
"uzzle",
|
||||
]
|
||||
|
||||
const NAME_SUFFIXES: Array[String] = ["y", "er", "o", "ok", "in"]
|
||||
|
||||
|
||||
func _gen_name() -> String:
|
||||
return (
|
||||
"%s%s%s"
|
||||
% [NAME_PREFIXES.pick_random(), NAME_ROOTS.pick_random(), NAME_SUFFIXES.pick_random()]
|
||||
)
|
||||
|
60
scenes/enemies/enemy_slime_small.gd
Normal file
60
scenes/enemies/enemy_slime_small.gd
Normal file
@@ -0,0 +1,60 @@
|
||||
class_name EnemySlimeSmall
|
||||
extends EnemyBase
|
||||
|
||||
@export var color: Color = Color.CHARTREUSE
|
||||
@onready var disabled_sprite: Sprite2D = $Sprite2D
|
||||
@onready var base_sprite: Sprite2D = $Sprite/BaseSprite
|
||||
|
||||
var shader = preload("res://assets/shaders/base_color_tint.gdshader")
|
||||
var shader_material: ShaderMaterial
|
||||
|
||||
const NAME_PREFIXES: Array[String] = [
|
||||
"Gl",
|
||||
"Sl",
|
||||
"Bl",
|
||||
"Pl",
|
||||
"Dr",
|
||||
"Go",
|
||||
"Glo",
|
||||
"Blo",
|
||||
]
|
||||
|
||||
const NAME_ROOTS: Array[String] = [
|
||||
"op",
|
||||
"ub",
|
||||
"ooz",
|
||||
"ump",
|
||||
"ibble",
|
||||
"ug",
|
||||
"urp",
|
||||
"lop",
|
||||
]
|
||||
|
||||
const NAME_SUFFIXES: Array[String] = [
|
||||
"y",
|
||||
"o",
|
||||
"let",
|
||||
"kin",
|
||||
"ish",
|
||||
"oo",
|
||||
]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
shader_material = ShaderMaterial.new()
|
||||
disabled_sprite.visible = false
|
||||
set_color(color)
|
||||
shader_material.shader = shader
|
||||
base_sprite.material = shader_material
|
||||
super._ready()
|
||||
|
||||
|
||||
func set_color(new_color: Color) -> void:
|
||||
shader_material.set_shader_parameter("base_color", new_color)
|
||||
|
||||
|
||||
func _gen_name() -> String:
|
||||
return (
|
||||
"%s%s%s"
|
||||
% [NAME_PREFIXES.pick_random(), NAME_ROOTS.pick_random(), NAME_SUFFIXES.pick_random()]
|
||||
)
|
1
scenes/enemies/enemy_slime_small.gd.uid
Normal file
1
scenes/enemies/enemy_slime_small.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c5wgwy5itcnkk
|
41
scenes/enemies/enemy_slime_small.tscn
Normal file
41
scenes/enemies/enemy_slime_small.tscn
Normal file
@@ -0,0 +1,41 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cjikar11hbp3b"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b7vq8xspnlyeu" path="res://scenes/enemies/enemy_base.tscn" id="1_o6v6p"]
|
||||
[ext_resource type="Script" uid="uid://c5wgwy5itcnkk" path="res://scenes/enemies/enemy_slime_small.gd" id="2_2bnvq"]
|
||||
[ext_resource type="Shader" uid="uid://cf48pgfl308o3" path="res://assets/shaders/base_color_tint.gdshader" id="3_2yvgl"]
|
||||
[ext_resource type="Texture2D" uid="uid://ctob5me7woid8" path="res://assets/sprites/slime_small grayscale.png" id="3_iaao1"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_daihb"]
|
||||
shader = ExtResource("3_2yvgl")
|
||||
shader_parameter/base_color = Color(3.46541e-06, 0.969973, 0.260278, 1)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2yvgl"]
|
||||
atlas = ExtResource("3_iaao1")
|
||||
region = Rect2(0, 15, 16, 15)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_daihb"]
|
||||
atlas = ExtResource("3_iaao1")
|
||||
region = Rect2(0, 30, 16, 15)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wu20c"]
|
||||
atlas = ExtResource("3_iaao1")
|
||||
region = Rect2(0, 45, 16, 15)
|
||||
|
||||
[node name="EnemySlimeSmall" instance=ExtResource("1_o6v6p")]
|
||||
script = ExtResource("2_2bnvq")
|
||||
color = Color(0.498039, 1, 0, 1)
|
||||
|
||||
[node name="Sprite" type="Node2D" parent="." index="0"]
|
||||
|
||||
[node name="BaseSprite" type="Sprite2D" parent="Sprite" index="0"]
|
||||
material = SubResource("ShaderMaterial_daihb")
|
||||
texture = SubResource("AtlasTexture_2yvgl")
|
||||
|
||||
[node name="Shading" type="Sprite2D" parent="Sprite" index="1"]
|
||||
texture = SubResource("AtlasTexture_daihb")
|
||||
|
||||
[node name="Highlights" type="Sprite2D" parent="Sprite" index="2"]
|
||||
texture = SubResource("AtlasTexture_wu20c")
|
||||
|
||||
[node name="Sprite2D" parent="." index="1"]
|
||||
visible = false
|
@@ -20,16 +20,16 @@ script = ExtResource("1_jyhfs")
|
||||
zoom = Vector2(2, 2)
|
||||
process_callback = 0
|
||||
|
||||
[node name="Player" parent="." node_paths=PackedStringArray("camera", "main_ui") instance=ExtResource("2_0wfyh")]
|
||||
position = Vector2(1057, 798)
|
||||
camera = NodePath("../MainCamera")
|
||||
main_ui = NodePath("../MainUI")
|
||||
|
||||
[node name="EnemyManager" parent="." node_paths=PackedStringArray("target", "camera") instance=ExtResource("5_tbgi4")]
|
||||
spawn_rate = 1.5
|
||||
target = NodePath("../Player")
|
||||
camera = NodePath("../MainCamera")
|
||||
|
||||
[node name="Player" parent="." node_paths=PackedStringArray("camera", "main_ui") instance=ExtResource("2_0wfyh")]
|
||||
position = Vector2(1057, 798)
|
||||
camera = NodePath("../MainCamera")
|
||||
main_ui = NodePath("../MainUI")
|
||||
|
||||
[node name="PickupMagnet" parent="." instance=ExtResource("6_tefeu")]
|
||||
position = Vector2(1697, 414)
|
||||
|
||||
|
19
scenes/main_menu.gd
Normal file
19
scenes/main_menu.gd
Normal file
@@ -0,0 +1,19 @@
|
||||
extends Control
|
||||
|
||||
const MAIN = preload("res://scenes/main.tscn")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_new_game_button_pressed() -> void:
|
||||
get_tree().change_scene_to_packed(MAIN)
|
||||
|
||||
|
||||
func _on_options_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_exit_game_button_pressed() -> void:
|
||||
get_tree().quit()
|
1
scenes/main_menu.gd.uid
Normal file
1
scenes/main_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://sd158y3mdmkt
|
69
scenes/main_menu.tscn
Normal file
69
scenes/main_menu.tscn
Normal file
@@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cynet50emve6c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://sd158y3mdmkt" path="res://scenes/main_menu.gd" id="1_l6cm7"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_vue75"]
|
||||
colors = PackedColorArray(0.252028, 0.252028, 0.252028, 1, 0.25098, 0.25098, 0.25098, 1)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_l6cm7"]
|
||||
gradient = SubResource("Gradient_vue75")
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_l6cm7")
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("GradientTexture1D_l6cm7")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -20.0
|
||||
offset_right = 20.0
|
||||
offset_bottom = 20.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="NewGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "New game"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
|
||||
[node name="ExitGameButton" type="Button" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Exit game"
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/NewGameButton" to="." method="_on_new_game_button_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/OptionsButton" to="." method="_on_options_button_pressed"]
|
||||
[connection signal="pressed" from="PanelContainer/MarginContainer/VBoxContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"]
|
@@ -10,6 +10,10 @@ extends Node2D
|
||||
|
||||
const ENEMY_RAT = preload("res://scenes/enemies/enemy_rat.tscn")
|
||||
const ENEMY_BAT = preload("res://scenes/enemies/enemy_bat.tscn")
|
||||
const ENEMY_SLIME_SMALL = preload("res://scenes/enemies/enemy_slime_small.tscn")
|
||||
const SLIME_COLOR_VARIATIONS: Array[Color] = [Color.CHARTREUSE, Color.FUCHSIA, Color.DARK_ORANGE]
|
||||
|
||||
var _elapsed_time: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -19,20 +23,34 @@ func _ready() -> void:
|
||||
GlobalConst.sig_set_spawn_rate.connect(_on_set_spawn_rate)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
_elapsed_time += delta
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
_on_set_spawn_rate(1.0 + (_elapsed_time / 60.0) ** 2)
|
||||
var enemies = get_tree().get_nodes_in_group(GlobalConst.GROUP_ENEMY)
|
||||
GlobalConst.sig_debug_stats_set.emit("enemy_count", "%s" % len(enemies))
|
||||
var next_enemy: PackedScene
|
||||
match randi() % 2:
|
||||
match randi() % 3:
|
||||
0:
|
||||
next_enemy = ENEMY_BAT
|
||||
1:
|
||||
next_enemy = ENEMY_RAT
|
||||
2:
|
||||
next_enemy = ENEMY_SLIME_SMALL
|
||||
|
||||
if len(enemies) < max_enemies:
|
||||
var new_enemy = next_enemy.instantiate()
|
||||
new_enemy.position = _get_spawn_pos()
|
||||
new_enemy.target = target
|
||||
if randf() < 0.1:
|
||||
new_enemy.enemy_rarity = GlobalConst.Rarity.RARE
|
||||
if randf() < 0.1:
|
||||
new_enemy.enemy_rarity = GlobalConst.Rarity.EPIC
|
||||
if is_instance_of(new_enemy, EnemySlimeSmall):
|
||||
var slime_color: Color = SLIME_COLOR_VARIATIONS.pick_random()
|
||||
new_enemy.color = slime_color
|
||||
add_child(new_enemy)
|
||||
|
||||
|
||||
@@ -94,4 +112,6 @@ func _on_stop_spawning(val: bool):
|
||||
|
||||
|
||||
func _on_set_spawn_rate(val: float):
|
||||
timer.wait_time = 1 / val
|
||||
timer.stop()
|
||||
timer.wait_time = 1.0 / val
|
||||
timer.start()
|
||||
|
@@ -13,13 +13,13 @@ signal lvlup_picked(mod: PlayerStatsModifier)
|
||||
|
||||
func _ready() -> void:
|
||||
match mod.rarity:
|
||||
GlobalConst.ModRarity.NORMAL:
|
||||
GlobalConst.Rarity.NORMAL:
|
||||
upgrade_name.add_theme_color_override("font_color", Color.WHITE)
|
||||
GlobalConst.ModRarity.RARE:
|
||||
GlobalConst.Rarity.RARE:
|
||||
upgrade_name.add_theme_color_override("font_color", Color.DODGER_BLUE)
|
||||
GlobalConst.ModRarity.EPIC:
|
||||
GlobalConst.Rarity.EPIC:
|
||||
upgrade_name.add_theme_color_override("font_color", Color.DARK_ORCHID)
|
||||
GlobalConst.ModRarity.LEGENDARY:
|
||||
GlobalConst.Rarity.LEGENDARY:
|
||||
upgrade_name.add_theme_color_override("font_color", Color.DARK_ORANGE)
|
||||
|
||||
upgrade_name.text = mod.title
|
||||
|
@@ -16,7 +16,7 @@ func pickup() -> void:
|
||||
mod.title = "Magnet"
|
||||
mod.tex = GlobalConst.placeholder_tex
|
||||
mod.internal_name = "magnet"
|
||||
mod.rarity = GlobalConst.ModRarity.RARE
|
||||
mod.rarity = GlobalConst.Rarity.RARE
|
||||
mod.stat_name = "pickup_radius"
|
||||
mod.value = 5000.0
|
||||
mod.type = PlayerStatsModifier.ModifierType.ABSOLUTE
|
||||
|
@@ -29,11 +29,6 @@ func _ready() -> void:
|
||||
if not weapon:
|
||||
weapon = WEAPON_SWORD.instantiate()
|
||||
add_child(weapon)
|
||||
var mod = WeaponModBase.new()
|
||||
mod.mod_property = "attack_damage"
|
||||
mod.mod_value = 10.0
|
||||
mod.mod_type = WeaponModBase.ModType.ADDITIVE
|
||||
weapon.add_mod(mod)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
@@ -8,6 +8,6 @@ var value: Variant
|
||||
var type: ModifierType = ModifierType.ADDITIVE
|
||||
var internal_name: String
|
||||
var title: String
|
||||
var rarity: GlobalConst.ModRarity
|
||||
var rarity: GlobalConst.Rarity
|
||||
var tex: Texture2D
|
||||
var description: String
|
||||
|
22
scenes/puddle.gd
Normal file
22
scenes/puddle.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
class_name Puddle
|
||||
extends Node2D
|
||||
|
||||
@export var color: Color = Color.CRIMSON
|
||||
@onready var base: Sprite2D = $Base
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var player: Player = get_tree().get_first_node_in_group(GlobalConst.GROUP_PLAYER)
|
||||
var shader = preload("res://assets/shaders/base_color_tint.gdshader")
|
||||
var shader_material: ShaderMaterial
|
||||
shader_material = ShaderMaterial.new()
|
||||
shader_material.set_shader_parameter("base_color", color)
|
||||
shader_material.shader = shader
|
||||
base.material = shader_material
|
||||
match randi() % 4:
|
||||
1:
|
||||
rotation_degrees = 90
|
||||
2:
|
||||
rotation_degrees = 180
|
||||
3:
|
||||
rotation_degrees = -90
|
1
scenes/puddle.gd.uid
Normal file
1
scenes/puddle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cds5aqq2mqmpe
|
34
scenes/puddle.tscn
Normal file
34
scenes/puddle.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://dcka1mmlgeoj7"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://cf48pgfl308o3" path="res://assets/shaders/base_color_tint.gdshader" id="1_qlq6d"]
|
||||
[ext_resource type="Script" uid="uid://cds5aqq2mqmpe" path="res://scenes/puddle.gd" id="1_s8xbh"]
|
||||
[ext_resource type="Texture2D" uid="uid://c5t4it4if0s6g" path="res://assets/sprites/puddle_1.png" id="2_s8xbh"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_i64cl"]
|
||||
shader = ExtResource("1_qlq6d")
|
||||
shader_parameter/base_color = Color(1, 0.2, 0.2, 1)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h42jt"]
|
||||
atlas = ExtResource("2_s8xbh")
|
||||
region = Rect2(0, 0, 16, 13)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_16dvh"]
|
||||
atlas = ExtResource("2_s8xbh")
|
||||
region = Rect2(32, 0, 16, 13)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5nuq4"]
|
||||
atlas = ExtResource("2_s8xbh")
|
||||
region = Rect2(16, 0, 16, 13)
|
||||
|
||||
[node name="Puddle" type="Node2D"]
|
||||
script = ExtResource("1_s8xbh")
|
||||
|
||||
[node name="Base" type="Sprite2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_i64cl")
|
||||
texture = SubResource("AtlasTexture_h42jt")
|
||||
|
||||
[node name="Highlights" type="Sprite2D" parent="."]
|
||||
texture = SubResource("AtlasTexture_16dvh")
|
||||
|
||||
[node name="Shading" type="Sprite2D" parent="."]
|
||||
texture = SubResource("AtlasTexture_5nuq4")
|
17
scenes/utils/keyed_cache.gd
Normal file
17
scenes/utils/keyed_cache.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
class_name KeyedCache
|
||||
extends Resource
|
||||
|
||||
var cache = {}
|
||||
|
||||
|
||||
func get_or_compute(key: String, compute_func: Callable):
|
||||
if key in cache:
|
||||
return cache["key"]
|
||||
|
||||
var value = compute_func.call()
|
||||
cache["key"] = value
|
||||
return value
|
||||
|
||||
|
||||
func invalidate_key(key: String):
|
||||
cache.erase(key)
|
1
scenes/utils/keyed_cache.gd.uid
Normal file
1
scenes/utils/keyed_cache.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bbshyok4m8nq3
|
@@ -4,6 +4,8 @@ extends Node2D
|
||||
enum WeaponTag {
|
||||
CAN_RETURN,
|
||||
CAN_BLEED,
|
||||
CAN_CHAIN,
|
||||
CAN_FORK,
|
||||
}
|
||||
|
||||
@export var attack_cd: float
|
||||
@@ -12,11 +14,21 @@ enum WeaponTag {
|
||||
@export var attack_duration: float
|
||||
@export var attack_range: float
|
||||
@export var attack_crit_chance: float = 0.05
|
||||
@export var return_chance: float = 0.0
|
||||
@export var bleed_chance: float = 0.0
|
||||
@export var bleed_duration: float = 5.0
|
||||
@export var chain_chance: float = 0.0
|
||||
@export var tags: Array[String] = []
|
||||
@export var modifiers: Array[WeaponModBase] = []
|
||||
|
||||
@onready var active_cd_timer: Timer = $ActiveCDTimer
|
||||
|
||||
var _player: Player
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_player = get_tree().get_first_node_in_group(GlobalConst.GROUP_PLAYER)
|
||||
|
||||
|
||||
func _on_attack_cd_timer_timeout() -> void:
|
||||
do_attack()
|
||||
@@ -76,3 +88,22 @@ func has_property(key: String) -> bool:
|
||||
if prop.name == key:
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func did_crit() -> bool:
|
||||
var weapon_crit = get_calculated("attack_crit_chance")
|
||||
var player_crit = _player.player_stats.get_final("crit_chance", _player.modifiers)
|
||||
|
||||
return randf() >= 1 - weapon_crit + player_crit
|
||||
|
||||
|
||||
func did_bleed() -> bool:
|
||||
return randf() >= 1 - bleed_chance
|
||||
|
||||
|
||||
func base_damage() -> Array[Variant]:
|
||||
var damage = get_calculated("attack_damage")
|
||||
var is_crit := did_crit()
|
||||
if is_crit:
|
||||
damage *= _player.player_stats.get_final("crit_multiplier", _player.modifiers)
|
||||
return [damage, is_crit]
|
||||
|
@@ -8,13 +8,12 @@ const WEAPON_SWORD_PROJECTILE = preload("res://scenes/weapons/weapon_sword_proje
|
||||
|
||||
signal projectile_hit(projectile: WeaponSwordProjectile, enemy: EnemyBase)
|
||||
|
||||
var _player: Player
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
bleed_chance = 0.2
|
||||
targeting_range_shape.shape.radius = attack_range
|
||||
projectile_hit.connect(_on_projectile_hit)
|
||||
_player = get_tree().get_first_node_in_group(GlobalConst.GROUP_PLAYER)
|
||||
super._ready()
|
||||
|
||||
|
||||
func do_attack() -> void:
|
||||
@@ -44,13 +43,13 @@ func _do_active() -> void:
|
||||
|
||||
|
||||
func deal_damage(enemy: EnemyBase, damage_mult: float):
|
||||
var weapon_crit = get_calculated("attack_crit_chance")
|
||||
var player_crit = _player.player_stats.get_final("crit_chance", _player.modifiers)
|
||||
var damage = get_calculated("attack_damage")
|
||||
var is_crit = randf() >= 1 - weapon_crit + player_crit
|
||||
if is_crit:
|
||||
damage *= _player.player_stats.get_final("crit_multiplier", _player.modifiers)
|
||||
enemy.take_damage(damage * damage_mult, is_crit)
|
||||
var damage_and_crit = base_damage()
|
||||
# TODO: Fix crit value
|
||||
enemy.take_damage(damage_and_crit[0], damage_and_crit[1])
|
||||
|
||||
if did_bleed():
|
||||
var bleed = EnemyEffectBleed.new(enemy, damage_and_crit[0], bleed_duration)
|
||||
bleed.apply(enemy)
|
||||
|
||||
|
||||
func _on_projectile_hit(projectile: WeaponSwordProjectile, enemy: EnemyBase, damage_mult: float):
|
||||
|
@@ -5,6 +5,7 @@ extends Node2D
|
||||
@export var range: float = 200.0
|
||||
@export var target: Node2D
|
||||
@export var damage_mult: float = 1.0
|
||||
@export var bleed_chance: float = 0.2
|
||||
@export var on_hit_sig: Signal
|
||||
|
||||
var _direction: Vector2
|
||||
|
Reference in New Issue
Block a user