Skip to content

Commit

Permalink
Merge pull request #8 from OctoD/feat/gameplay-abilities
Browse files Browse the repository at this point in the history
feat: adds gameplay ability system
  • Loading branch information
OctoD authored Mar 14, 2023
2 parents 66fe118 + 1355e08 commit 7ec159a
Show file tree
Hide file tree
Showing 89 changed files with 2,239 additions and 401 deletions.
8 changes: 4 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
.github export-ignore
.gitignore export-ignore
CODE_OF_CONDUCT.md export-ignore
docs export-ignore
example export-ignore
icon.svg export-ignore
icon.svg.import export-ignore
example export-ignore
icons.sketch export-ignore
LICENCE export-ignore
README.md export-ignore
stats-icon.png export-ignore
stats-icon.png.import export-ignore
README.md export-ignore
74 changes: 12 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
⚔️ Gameplay Attributes ⚔️
=========================
⚔️ GGS ⚔️
=======

Gameplay attributes are a set of nodes used to describe some
characters attributes for both 2D and 3D games made with Godot.
Godot Gameplay Systems (formerly godot gameplay attributes) is a set of nodes and resources which speed up development of skills and attribute based gameplay mechanisms.

- [⚔️ Gameplay Attributes ⚔️](#️-gameplay-attributes-️)
- [⚔️ GGS ⚔️](#️-ggs-️)
- [Install](#install)
- [How it works](#how-it-works)
- [Api/methods/classes](#apimethodsclasses)
- [GameplayAttributeMap](#gameplayattributemap)
- [signals](#signals)
- [methods](#methods)
- [How does it work?](#how-does-it-work)
- [Networking Attributes, Effects and Abilities](#networking-attributes-effects-and-abilities)
- [Contribution](#contribution)
- [Licence](#licence)

Expand All @@ -20,63 +16,17 @@ Clone this repo inside your `addons` directory.

Enable this plugin by going to `project settings/plugins`.

Enjoy!
Enjoy!

# How it works
## How does it work?

It is very simple (dead simple enough I would say, longer to write and read than to use):
You can check some tutorials/doc/examples [here](./docs/readme.md)

You in-game entities which should have some kind of attributes (life, endurance, mana, stamina, jump force etc) must have a `GameplayAttributeMap` node.
I am making also a small "game" to demonstrate how things work. You can check it out opening this repository using godot 4.x (stable) and pressing the play button.

You have to specify both a `owning character` property assigning a node.
# Networking Attributes, Effects and Abilities

This node accepts an `AttributeTable` resource as value. This resource specifies which attributes the entity has.

Once specified a table, the inspector will show you these attributes, where you can set a:

- minimum value: which usually is zero
- maximum value: if you set it to zero, there will be not a maximum
- current value: the starting value for the entity

Now, to change these attributes, you will need some kind of "effects", in the form of `GameplayEffect` nodes.

A `GameplayEffect` requires an `AttributeTable` resource (like `GameplayAttributeMap`) and can specify an unlimited number of attributes alterations to it.

Once you setupped your `GameplayEffect`, you can add it to the character and here the magic happens, the attributes are changed magically.

You can use `EffectedArea2D` or `EffectedArea3D` to automatically apply effects on collisions (although you should extend them to validate to who you should apply the effect)

Done, more simple than previous versions.

You can check this repository example project to better understand and play directly with the addon.

# Api/methods/classes

## GameplayAttributeMap

#### signals

```gdscript
# called when an attribute changes
signal attribute_changed(attribute: AttributeSpec)
# called each time an attribute is changed by an attribute effect
attribute_effect_applied(attribute_effect: AttributeEffect)
# called each time an attribute effect is removed
attribute_effect_removed(attribute_effect: AttributeEffect)
# called when a gameplay effect is applied
effect_applied(effect: GameplayEffect)
```

#### methods

```gdscript
# applies an effect to the owning character
func apply_effect(effect: GameplayEffect) -> void:
# searches an attribute by name
# returns an instance of AttributeSpec or null if none
func get_attribute_by_name(attribute_name: String) -> AttributeSpec
```
Did not test too much, but abilities, effects and attributes could be simply replicated using the `MultiplayerSynchronizer` node provided by godot4.x.


# Contribution
Expand Down
Binary file removed addons/godot-gameplay-attributes/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed addons/godot-gameplay-attributes/assets/timed_icon.png
Binary file not shown.
34 changes: 0 additions & 34 deletions addons/godot-gameplay-attributes/assets/timed_icon.png.import

This file was deleted.

7 changes: 0 additions & 7 deletions addons/godot-gameplay-attributes/plugin.cfg

This file was deleted.

14 changes: 14 additions & 0 deletions addons/godot_gameplay_systems/assets/Ability.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://7uv04bueo6h2"
path="res://.godot/imported/attribute_icon.png-b2f25314d318c523571e1561cd1646ad.ctex"
uid="uid://c2d8ar1vogsgq"
path="res://.godot/imported/Ability.svg-e0d7b30e4febf5ebd1b30c2234360bea.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/godot-gameplay-attributes/assets/attribute_icon.png"
dest_files=["res://.godot/imported/attribute_icon.png-b2f25314d318c523571e1561cd1646ad.ctex"]
source_file="res://addons/godot_gameplay_systems/assets/Ability.svg"
dest_files=["res://.godot/imported/Ability.svg-e0d7b30e4febf5ebd1b30c2234360bea.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand All @@ -32,3 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
20 changes: 20 additions & 0 deletions addons/godot_gameplay_systems/assets/AbilityContainer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions addons/godot_gameplay_systems/assets/AbilityContainer.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dn54fmpqnjrlm"
path="res://.godot/imported/AbilityContainer.svg-055e9f498904d8de8c91ea25f79bd753.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/godot_gameplay_systems/assets/AbilityContainer.svg"
dest_files=["res://.godot/imported/AbilityContainer.svg-055e9f498904d8de8c91ea25f79bd753.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
15 changes: 15 additions & 0 deletions addons/godot_gameplay_systems/assets/Attribute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://c8tgvn7iityox"
path="res://.godot/imported/effect_icon.png-f7fc7c9333a962e0e2749e7d3b6ce6b7.ctex"
uid="uid://cp7geybwp22pi"
path="res://.godot/imported/Attribute.svg-fbb53d6f1fb2d051a8d4565b42b7b819.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/godot-gameplay-attributes/assets/effect_icon.png"
dest_files=["res://.godot/imported/effect_icon.png-f7fc7c9333a962e0e2749e7d3b6ce6b7.ctex"]
source_file="res://addons/godot_gameplay_systems/assets/Attribute.svg"
dest_files=["res://.godot/imported/Attribute.svg-fbb53d6f1fb2d051a8d4565b42b7b819.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
Expand All @@ -32,3 +32,6 @@ process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
15 changes: 15 additions & 0 deletions addons/godot_gameplay_systems/assets/AttributeEffect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7ec159a

Please sign in to comment.