-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tons of fixes + Combat3D sub-node to give combat attributes.
- Loading branch information
Showing
9 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extends Node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@icon("res://editor/icons/GameTime.svg") | ||
|
||
# Simple class, place in the tree and access easily, contains a global float | ||
# that holds the time elapsed since the scene has been booted up. | ||
class_name GameTime | ||
extends Node | ||
|
||
var _curtime: float = 0; | ||
func _process(delta): | ||
_curtime += delta; | ||
|
||
var elapsed_time: float: | ||
get: | ||
return _curtime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2023 - Nick S. - All Rights Reserved. | ||
# =================================================== | ||
# This file was shared publicly, please do not remove | ||
# this credit part. | ||
# https://github.com/urnotnick/godot-stuff | ||
# =================================================== | ||
class_name Combat3D | ||
extends Node3D | ||
|
||
@onready var _owner = get_parent_node_3d(); | ||
@export var starting_health: float = 100; | ||
@export var maximum_health: float = 100; | ||
|
||
# Private prop; | ||
var _health: float = 100; | ||
var health: float = 100: | ||
get: | ||
return (_health); | ||
|
||
func _death(attacker: Combat3D) -> void: | ||
pass | ||
|
||
func _take_damage(attacker: Combat3D, damage: float, normal: Vector3, force: Vector3) -> void: | ||
pass; | ||
|
||
func _scale_damage(attacker: Combat3D, damage: float, normal: Vector3, force: Vector3) -> float: | ||
return 1.0; | ||
|
||
# This has to be called within _process_physics, otherwise you get bad results. | ||
func inflict_damage(attacker: Combat3D, damage: float, normal: Vector3, force: Vector3, pos: Vector3) -> void: | ||
get_parent_node_3d().apply_impulse(force); | ||
damage = _scale_damage(attacker, damage, normal, force); | ||
_health -= damage; | ||
_take_damage(attacker, damage, normal, force); | ||
if (_health <= 0): | ||
_death(attacker); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2023 - Nick S. - All Rights Reserved. | ||
# =================================================== | ||
# This file was shared publicly, please do not remove | ||
# this credit part. | ||
# https://github.com/urnotnick/godot-stuff | ||
# =================================================== | ||
extends Node; | ||
func assert_instance(node_instance: Node) -> Node: | ||
assert(node_instance != null, "Assertion of NULL instance."); | ||
return node_instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters