many renames, basic exp earning

This commit is contained in:
tonydero 2024-10-20 16:44:08 -06:00
parent 3ddee847e2
commit ccdee2e057
19 changed files with 164 additions and 57 deletions

3
.gitignore vendored
View File

@ -16,4 +16,5 @@ export_presets.cfg
data_*/ data_*/
mono_crash.*.json mono_crash.*.json
# codium stuff
.VSCodeCounter

View File

@ -34,3 +34,7 @@ project/assembly_name="Semi-Idle ARPG"
[editor_plugins] [editor_plugins]
enabled=PackedStringArray("res://addons/godot-vim/plugin.cfg") enabled=PackedStringArray("res://addons/godot-vim/plugin.cfg")
[physics]
common/physics_ticks_per_second=120

View File

@ -6,6 +6,8 @@
[node name="NPCEnemy" type="CharacterBody2D"] [node name="NPCEnemy" type="CharacterBody2D"]
script = ExtResource("1_ec4cy") script = ExtResource("1_ec4cy")
npcDifficulty = 2
npcTier = 4
[node name="CollisionShape2D" type="CollisionPolygon2D" parent="."] [node name="CollisionShape2D" type="CollisionPolygon2D" parent="."]
position = Vector2(-100, -86) position = Vector2(-100, -86)

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=15 format=3 uid="uid://0h3dpe6fuhe8"] [gd_scene load_steps=16 format=3 uid="uid://0h3dpe6fuhe8"]
[ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"] [ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"]
[ext_resource type="Theme" uid="uid://clhh3c3gxotjg" path="res://assets/healthbar.tres" id="2_2v2l0"] [ext_resource type="Theme" uid="uid://clhh3c3gxotjg" path="res://assets/healthbar.tres" id="2_2v2l0"]
[ext_resource type="Script" path="res://scripts/WorldArea.gd" id="2_ccxbh"] [ext_resource type="Script" path="res://scripts/WorldArea.gd" id="2_ccxbh"]
[ext_resource type="PackedScene" uid="uid://dvwo26vsk46tl" path="res://scenes/ability_player.tscn" id="2_heria"] [ext_resource type="PackedScene" uid="uid://dvwo26vsk46tl" path="res://scenes/ability_player.tscn" id="2_heria"]
[ext_resource type="Script" path="res://scripts/Player.gd" id="3_cjiwt"]
[ext_resource type="Theme" uid="uid://cp82s71sduhcv" path="res://assets/expbar.tres" id="3_n8q4b"] [ext_resource type="Theme" uid="uid://cp82s71sduhcv" path="res://assets/expbar.tres" id="3_n8q4b"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6qo1s"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6qo1s"]
@ -92,6 +93,7 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_imvmd")
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
script = ExtResource("3_cjiwt")
[node name="PlayerLabel" type="HBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"] [node name="PlayerLabel" type="HBoxContainer" parent="MarginContainer/UIBottom/PlayerContainer/PlayerInfo"]
layout_mode = 2 layout_mode = 2
@ -198,14 +200,16 @@ alignment = 1
[node name="AbilityA1" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")] [node name="AbilityA1" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")]
custom_minimum_size = Vector2(64, 64) custom_minimum_size = Vector2(64, 64)
layout_mode = 2 layout_mode = 2
attack_range = 600 attack_range = 9999
attack_damage = 999999
[node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")] [node name="AbilityA2" parent="MarginContainer/UIBottom/UIBottomCenter/AbilityBar" instance=ExtResource("2_heria")]
visible = false
custom_minimum_size = Vector2(64, 64) custom_minimum_size = Vector2(64, 64)
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 6 size_flags_horizontal = 6
attack_range = 200
target_type = 3 target_type = 3
attack_range = 200
attack_damage = 50 attack_damage = 50
auto_speed = 5.0 auto_speed = 5.0

View File

@ -3,19 +3,7 @@ class_name AbilityBase
extends TextureRect extends TextureRect
enum TargTypes {
SINGLE,
CLEAVE,
CHAIN,
SWIPE,
WAVE,
AREA,
RAY,
}
@export var attack_range := 0 @export var attack_range := 0
@export var target_type := TargTypes.SINGLE @export var damage_type := Globals.Ability.PDamageType.SLICE
@export var damage_type := Globals.Ability.PDmgTypes.SLICE
@export var attack_damage := 200 @export var attack_damage := 200
@export var auto_speed := 1.0 @export var auto_speed := 1.0

View File

@ -6,6 +6,19 @@ extends AbilityBase
var middleX var middleX
var playerPos var playerPos
enum TargetType {
SINGLE,
CLEAVE,
CHAIN,
SWIPE,
WAVE,
AREA,
RAY,
}
@export var target_type := TargetType.SINGLE
@export var target_angle := 2*PI
@export var base_cooldown := 0.0 @export var base_cooldown := 0.0
func _ready() -> void: func _ready() -> void:
@ -42,39 +55,62 @@ func _get_target(enemies) -> Node:
# get list of distances by mapping distance to each node in enemies # get list of distances by mapping distance to each node in enemies
enemyDists = enemies.map(_get_distsq_to_player) enemyDists = enemies.map(_get_distsq_to_player)
# get closest enemy by finding first index with min dist # get closest enemy by finding first index with min dist
if enemyDists.min() <= self.attack_range**2: if enemyDists.min() <= self.attack_range ** 2:
closestEnemy = enemies[enemyDists.find(enemyDists.min())] closestEnemy = enemies[enemyDists.find(enemyDists.min())]
return closestEnemy return closestEnemy
func _get_targets(enemies) -> Array: func _get_targets_in_range(enemies) -> Array:
var enemyDists var enemyDists
var enemiesInRange := [] var enemiesInRange := []
# get list of distances by mapping distance to each node in enemies # get list of distances by mapping distance to each node in enemies
enemyDists = enemies.map(_get_distsq_to_player) enemyDists = enemies.map(_get_distsq_to_player)
# append enemies in range to enemiesInRange # append enemies in range to enemiesInRange
for i in range(enemies.size()): for i in range(enemies.size()):
if enemyDists[i] <= self.attack_range**2: if enemyDists[i] <= self.attack_range ** 2:
enemiesInRange.append(enemies[i]) enemiesInRange.append(enemies[i])
return enemiesInRange return enemiesInRange
# func _get_targets_in_angle(enemies) -> Array:
# var enemyAngles
# var enemiesInAngle := []
# # get list of angles by mapping distance to each node in enemies
# enemyAngles = enemies.map(_get_angle_to_player)
# # append enemies in range to enemiesInAngle
# for i in range(enemies.size()):
# if enemyAngles[i] <= self.attack_range ** 2:
# enemiesInAngle.append(enemies[i])
# return enemiesInAngle
# func _get_targets(enemies) -> Array:
# if self.attack_range > 0:
# var enemiesInRange = _get_targets_in_range(enemies)
func _apply_status() -> void:
# TODO: Try passing damage and status type to target for mods, e.g. burning or stunned, and use with singleton stats to add thread to target for damage or do other things depending on the case
pass
func _deal_idle_damage(enemiesList) -> void: func _deal_idle_damage(enemiesList) -> void:
match target_type: match target_type:
TargTypes.SINGLE: TargetType.SINGLE:
var target = _get_target(enemiesList) var target = _get_target(enemiesList)
if target: if target:
target.damageTaken += attack_damage target.damageTaken += attack_damage
_: _:
var targets = _get_targets(enemiesList) var targets = _get_targets_in_range(enemiesList)
if targets: if targets:
for target in targets: for target in targets:
target.damageTaken += attack_damage target.damageTaken += attack_damage
func _on_idle_cooldown_timeout() -> void: func _on_idle_cooldown_timeout() -> void:
var enemiesList = _get_enemies() var enemiesList = _get_enemies()
if not enemiesList.is_empty() and self.visible: if not enemiesList.is_empty() and self.visible:

View File

@ -2,26 +2,30 @@
extends Node extends Node
class World: class World:
enum Zones { enum Zone {
TUTORIAL, TUTORIAL,
} }
enum AreaTypes { enum AreaType {
PEACEFUL, PEACEFUL,
URBAN, URBAN,
WILDS, WILDS,
DEEP_WILDS, DEEP_WILDS,
DUNGEON, DUNGEON,
} }
enum Faction {
CREATURE,
MONSTER,
}
class Ability: class Ability:
enum PDmgTypes { enum PDamageType {
SLICE, SLICE,
PUNCTURE, PUNCTURE,
BASH, BASH,
HACK, HACK,
SHRED, SHRED,
} }
enum MDmgTypes { enum MDamageType {
BURN, BURN,
FREEZE, FREEZE,
SHOCK, SHOCK,
@ -32,11 +36,12 @@ class Ability:
ARCANE, ARCANE,
FORCE FORCE
} }
enum SModTypes { enum StatusModType {
STUN, STUN,
SLOW, SLOW,
ABSORB, ABSORB,
SHIELD, SHIELD,
DOT,
DOTB, DOTB,
DOTE DOTE
} }

View File

@ -1,5 +1,5 @@
class_name Gear class_name Gear
extends "item.gd" extends Item
# the basic stats that occur on gear # the basic stats that occur on gear

View File

@ -13,6 +13,7 @@ signal npc_died(npcTier: NPCTier)
@export var damageTaken := 0 @export var damageTaken := 0
@export var npcDifficulty: NPCDifficulty @export var npcDifficulty: NPCDifficulty
@export var npcTier: NPCTier @export var npcTier: NPCTier
@export var faction: Globals.World.Faction
func _random_mod_health() -> void: func _random_mod_health() -> void:
randomize() randomize()
@ -37,9 +38,9 @@ func _random_mod_health() -> void:
self.maxHealth *= 10 self.maxHealth *= 10
func _init() -> void: # func _init() -> void:
self.npcDifficulty = NPCDifficulty.NORMAL # self.npcDifficulty = NPCDifficulty.NORMAL
self.npcTier = NPCTier.I # self.npcTier = NPCTier.I
func _ready() -> void: func _ready() -> void:

View File

@ -3,22 +3,24 @@ class_name NPCEnemy
extends NPC extends NPC
@export var killType: WorldArea.Faction = WorldArea.Faction.CREATURE
var target var target
var speed := 200 var speed := 200
var prevCollisions := 0 var prevCollisions := 0
func _init() -> void: # func _init() -> void:
# TODO: randomize within area restrictions? or put this in area? # # TODO: randomize within area restrictions? or put this in area?
self.npcDifficulty = NPCDifficulty.NORMAL # self.npcDifficulty = NPCDifficulty.NORMAL
self.npcTier = NPCTier.I # self.npcTier = NPCTier.I
func _ready() -> void: func _ready() -> void:
# add to enemies # add to enemies
add_to_group("enemies") add_to_group("enemies")
# set faction
self.faction = Globals.World.Faction.CREATURE
# set health # set health
_random_mod_health() _random_mod_health()
@ -33,12 +35,13 @@ func _process(_delta: float) -> void:
if damageTaken >= maxHealth: if damageTaken >= maxHealth:
# save vars to emit # save vars to emit
var enemyDifficulty = self.npcDifficulty var enemyDifficulty = self.npcDifficulty
var enemyKillType = self.killType var enemyFaction = self.faction
var enemyTier = self.npcTier
# delete node # delete node
self.remove_from_group("enemies") self.remove_from_group("enemies")
self.queue_free() self.queue_free()
# send signal that I died to be counted, etc. # send signal that I died to be counted, etc.
SignalBus.enemy_died.emit(enemyDifficulty, enemyKillType) SignalBus.enemy_died.emit(enemyDifficulty, enemyTier, enemyFaction)
func _physics_process(_delta): func _physics_process(_delta):

8
scripts/Player.cs Normal file
View File

@ -0,0 +1,8 @@
// player class
using Godot;
public class Player
{
public int playerLevel;
public int playerExp;
}

46
scripts/Player.gd Normal file
View File

@ -0,0 +1,46 @@
# player class
class_name Player
extends VBoxContainer
var area_exp := 0.0
func _ready() -> void:
SignalBus.enemy_died.connect(_on_enemy_died)
SignalBus.quest_completed.connect(_on_quest_completed)
$PlayerExpBar.value = _get_level_progress_percent()
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.player_level))
func _on_enemy_died(enemyDifficulty, enemyTier, _enemyFaction) -> void:
var kill_exp = pow(pow(enemyTier + 1, 3), enemyDifficulty)
area_exp += kill_exp
print("T: ", enemyTier, " D: ", enemyDifficulty)
print("K: ", kill_exp)
print("A: ",area_exp)
# TODO: maybe show earned exp on bar, separate from current
# use xp to next level and current level, subtract, figure out percentage per point exp, add to display?
func _calculate_player_level() -> float:
var current_exp = PlayerState.player_exp
return log((current_exp + 5)/5.0) + 1
func _get_level_progress_percent() -> float:
var current_level = _calculate_player_level()
return fmod(current_level, 1) * 100.0
func _on_quest_completed() -> void:
PlayerState.player_exp += area_exp
PlayerState.player_level = _calculate_player_level()
$PlayerExpBar.value = _get_level_progress_percent()
$PlayerLabel/PlayerLevel.text = str(floor(PlayerState.player_level))
print("FA: ", area_exp)
print("L: ", PlayerState.player_level)
print("XP: ", PlayerState.player_exp)
print("CL: ", _calculate_player_level())
print("LP: ", _get_level_progress_percent())
Engine.time_scale = 0.0001

View File

@ -3,7 +3,7 @@ extends Node
@export var player_constitution := 1 @export var player_constitution := 1
@export var player_exp := 0 @export var player_exp := 0.0
@export var player_level := 1 @export var player_level := 1.0
@export var player_maxhealth := player_constitution * player_level * 100 @export var player_maxhealth := player_constitution * player_level * 100
@export var player_currenthealth := player_maxhealth @export var player_currenthealth := player_maxhealth

View File

@ -1,9 +1,11 @@
# quest class, impleeenting all quest functionality
# TODO: implement zone quests
class_name Quest class_name Quest
extends PanelContainer extends PanelContainer
@export var goalType := WorldArea.GoalType.KILL @export var goalType := WorldArea.GoalType.KILL
@export var faction := WorldArea.Faction.CREATURE @export var faction := Globals.World.Faction.CREATURE
@export var goalTotal := 1 @export var goalTotal := 1
@export var goalCurrent := 0 @export var goalCurrent := 0
@ -25,7 +27,7 @@ func _process(_delta: float) -> void:
func _set_goal_text() -> void: func _set_goal_text() -> void:
var goalStr = WorldArea.GoalType.keys()[self.goalType].capitalize() var goalStr = WorldArea.GoalType.keys()[self.goalType].capitalize()
var factionStr = WorldArea.Faction.keys()[self.faction].capitalize() var factionStr = Globals.World.Faction.keys()[self.faction].capitalize()
$QuestProgress/GoalTypeVal.text = goalStr + " " + factionStr + "s" $QuestProgress/GoalTypeVal.text = goalStr + " " + factionStr + "s"
@ -33,7 +35,7 @@ func _set_goal_val() -> void:
$QuestProgress/GoalVal.text = str(self.goalTotal) $QuestProgress/GoalVal.text = str(self.goalTotal)
func _quest_goal_check(enemyKillType: WorldArea.Faction) -> void: func _quest_goal_check(enemyKillType: Globals.World.Faction) -> void:
if enemyKillType == self.faction: if enemyKillType == self.faction:
self.goalCurrent += 1 self.goalCurrent += 1
$QuestProgress/CompletedVal.text = str(self.goalCurrent) $QuestProgress/CompletedVal.text = str(self.goalCurrent)
@ -51,14 +53,18 @@ func _quest_complete_show() -> void:
func _generate_random_quest() -> void: func _generate_random_quest() -> void:
# TODO: generate random quest # TODO: generate acutally random quest
self.goalType = WorldArea.GoalType.KILL self.goalType = WorldArea.GoalType.KILL
self.faction = WorldArea.Faction.CREATURE self.faction = Globals.World.Faction.CREATURE
self.goalTotal = randi_range(20, 50) self.goalTotal = randi_range(20, 50)
# match self.goalType: # match self.goalType:
# GoalTypes.KILLMANY: # GoalTypes.KILLMANY:
# self.faction = KillTypes.NATURAL # self.faction = KillTypes.NATURAL
func _on_enemy_died(_enemyDifficulty: NPC.NPCDifficulty, enemyFaction: WorldArea.Faction): func _on_enemy_died(
_enemyDifficulty: NPC.NPCDifficulty,
_enemyTier: NPC.NPCTier,
enemyFaction: Globals.World.Faction,
):
_quest_goal_check(enemyFaction) _quest_goal_check(enemyFaction)

View File

@ -2,6 +2,10 @@
extends Node extends Node
signal enemy_died(npcDifficulty: NPC.NPCDifficulty, faction: WorldArea.Faction) signal enemy_died(
npcDifficulty: NPC.NPCDifficulty,
npcTier: NPC.NPCTier,
faction: Globals.World.Faction,
)
signal enemy_damaged_player signal enemy_damaged_player
signal quest_completed signal quest_completed

View File

@ -4,9 +4,8 @@ extends PanelContainer
enum GoalType {KILL, FIND} enum GoalType {KILL, FIND}
enum Faction {CREATURE, MONSTER}
@export var area_type := Globals.World.AreaTypes.WILDS @export var area_type := Globals.World.AreaType.WILDS
# instantiate Quest # instantiate Quest

View File

@ -2,5 +2,5 @@
extends Node extends Node
@export var current_zone: Globals.World.Zones @export var current_zone: Globals.World.Zone
@export var last_played: Dictionary @export var last_played: Dictionary

View File

@ -1,5 +1,5 @@
class_name GearRandom class_name GearRandom
extends "gear.gd" extends Gear
func _init(): func _init():

View File

@ -3,7 +3,7 @@ extends Control
@export var debug = false @export var debug = false
@export var spawnTimerValue = 5.0 @export var spawnTimerValue = 10.0
var deltaCount := 0 var deltaCount := 0
var enemyMoveSpeed := 5.0 var enemyMoveSpeed := 5.0
@ -17,7 +17,7 @@ var playerPos
func _ready() -> void: func _ready() -> void:
if debug: if debug:
%DebugMenu.show() %DebugMenu.show()
Engine.time_scale = 3.0 Engine.time_scale = 10.0
SignalBus.quest_completed.connect(_on_quest_completed) SignalBus.quest_completed.connect(_on_quest_completed)
SignalBus.enemy_damaged_player.connect(_on_enemy_damaged_player) SignalBus.enemy_damaged_player.connect(_on_enemy_damaged_player)
@ -30,7 +30,7 @@ func _ready() -> void:
_set_player_display() _set_player_display()
$SpawnTimer.start(spawnTimerValue) $SpawnTimer.start(spawnTimerValue)
_spawn_enemies(1) _spawn_enemies(randi_range(1, 5))
# _spawn_enemies(5) # _spawn_enemies(5)
@ -83,7 +83,7 @@ func _on_button_exit_pressed() -> void:
func _on_spawn_timer_timeout() -> void: func _on_spawn_timer_timeout() -> void:
_spawn_enemies(1) _spawn_enemies(randi_range(1, 5))
func _get_player_current_health() -> void: func _get_player_current_health() -> void:
@ -91,7 +91,7 @@ func _get_player_current_health() -> void:
%PlayerInfo/PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath) %PlayerInfo/PlayerHealthBar/PlayerHealthCurrent.text = str(playerCurrHeath)
%PlayerInfo/PlayerHealthBar.value = playerCurrHeath %PlayerInfo/PlayerHealthBar.value = playerCurrHeath
if playerCurrHeath <= 0: if playerCurrHeath <= 0:
get_tree().paused = true Engine.time_scale = 0.0001
func _set_player_display() -> void: func _set_player_display() -> void: