2019-11-22 00:55:01 +01:00
|
|
|
# Entity Spell System
|
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
An entity and spell system for the GODOT Engine, that is usable for both 2d, and 3d games. The main purpose of this
|
|
|
|
module is to handle spells, auras, and most entity-related things like spawning, items, inventory, contaiers,
|
|
|
|
vendors, interaction, targeting, equipment (+ visuals), loot, crafting, talents, pets, npcs, etc ...
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
The module supports networking. It is designed to be authoritative, so players shouldn't be able to cheat by design.
|
2020-03-09 00:35:48 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
It is a c++ engine module, which means you will need to compile it into godot. (See compiling)
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
It supports godot 3.2 at the moment.
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
### What the module doesn't cover
|
|
|
|
|
|
|
|
Movement, and controls.
|
|
|
|
|
|
|
|
Unfortunately, there isn't a one-stop-shop solution for movement, especially if we throw networking into the mix,
|
|
|
|
and the same is true for targeting. This means that this module cannot really do much in this regard, but it will
|
|
|
|
give you as much help to set everything up as possible.
|
|
|
|
|
|
|
|
## Optional Dependencies
|
|
|
|
|
|
|
|
Mesh Data Resource
|
|
|
|
|
|
|
|
https://github.com/Relintai/mesh_data_resource.git
|
|
|
|
|
2020-05-19 21:09:00 +02:00
|
|
|
Adds mesh support to ModelVisuals. This is exists because in gles2 mesh data cannot be accessed directly from ArrayMeshes.
|
2020-04-08 03:24:48 +02:00
|
|
|
|
2020-04-08 03:26:28 +02:00
|
|
|
## Overview
|
2020-04-08 03:24:48 +02:00
|
|
|
|
|
|
|
The module provides a huge number of script callbacks, usually as virtual methods they usually start with an underscore.
|
|
|
|
|
|
|
|
Do not call methods with underscores, all of them has a normal counterpart, always call that.
|
|
|
|
|
2020-04-28 15:41:48 +02:00
|
|
|
For example entity has `crafts(int id)` and `_crafts(int id)` (virtual). Always use `crafts(int id)`, it will
|
|
|
|
call `_crafts(int id)`.
|
2020-04-08 03:24:48 +02:00
|
|
|
|
|
|
|
For networked classes, every variable is broken up into clientside, and serverside. This makes it easier to
|
|
|
|
develop games that can also run locally, with less overhead and simpler logic.
|
|
|
|
E.g. this makes it easy to use the visibility system even when you play locally on the server, because you just use the clientside variables,
|
|
|
|
and your logic will work the same way.
|
|
|
|
|
|
|
|
## Entity
|
|
|
|
|
|
|
|
This is the main class that can be used for players/mobs/npcs and also other things like chests.
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
I ended up merging subclass functionality into it, because
|
|
|
|
that way it gains a lot more utility, by sacrificing only a small amount of memory.
|
2019-11-22 00:55:01 +01:00
|
|
|
For example this way it is easy to make chests attack the player, or make spell that animate objects.
|
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
### Spawning
|
|
|
|
|
|
|
|
Since spawning (= creating) entities is entirely dependant on the type of game you are making, ESS cannot do
|
|
|
|
everything for you. It will set up stats, equipment etc, but there is no way to set up positions for example.
|
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
You can implement your spawning logic by inheriting from ESSEntitySpawner, and implementing `_request_entity_spawn`.
|
2020-04-08 03:24:48 +02:00
|
|
|
|
2020-04-18 14:31:36 +02:00
|
|
|
You will need to register this spawner into the ESS singleton, either by using `setup(resource_db, entity_spawner)`, or
|
|
|
|
by using the provided property/setter `entity_spawner`/`set_entity_spawner()`.
|
|
|
|
|
|
|
|
The ESS singleton also contains convenience methods to request spawning an Entity.
|
2020-04-08 03:24:48 +02:00
|
|
|
|
|
|
|
#### EntityCreateInfo
|
|
|
|
|
|
|
|
Entity spawning usually requires a lot of complexity and hassle, this helper class aims to make it painless.
|
|
|
|
|
|
|
|
All methods that deal with spawning will take this as a parameter.
|
|
|
|
|
|
|
|
### EntityData
|
|
|
|
|
|
|
|
Since setting up Entities as scenes is usually quite the hassle, `EntityData` had to be created.
|
|
|
|
|
|
|
|
It stores everything an entity needs.
|
|
|
|
|
|
|
|
In order to spawn an entity you need it.
|
|
|
|
|
|
|
|
### AI
|
|
|
|
|
|
|
|
You can implement ai by extending `EntityAI`, and then assigning it to an EntityData.
|
|
|
|
|
|
|
|
When an `Entity` gets spawned it will create a copy for itself, so you can safely use class variables.
|
|
|
|
|
|
|
|
### Bags
|
|
|
|
|
|
|
|
Stores item. See `Bag`. It has aquite a few virtual methods, you should be able to implement most inventory types
|
|
|
|
should you want to.
|
|
|
|
|
|
|
|
Entity will send these over the network.
|
|
|
|
|
|
|
|
Also Entities have a target bag property. For example this makes vendors easily implementable.
|
|
|
|
|
|
|
|
### VRPCs
|
|
|
|
|
|
|
|
Entities has a networked visibility system. The method itself is called `vrpc`, it works the same way as normal rpcs.
|
|
|
|
If you want to send data to every client that sees the current entity, use this.
|
|
|
|
|
|
|
|
## Spells, Auras
|
|
|
|
|
2019-11-22 00:55:01 +01:00
|
|
|
Spell is the class you need to create spells, it stores the data, and also it has the ability to be scripted.
|
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
Aura is also built the same way as spells.
|
|
|
|
|
|
|
|
### Infos / Pipelines
|
|
|
|
|
|
|
|
SpellCastInfo
|
|
|
|
|
|
|
|
Stores information about the state of a spell's cast.
|
|
|
|
|
|
|
|
AuraApplyInfo
|
|
|
|
|
|
|
|
Helps to apply auras
|
|
|
|
|
|
|
|
SpellDamageInfo, SpellHealInfo
|
|
|
|
|
|
|
|
These are used in the damage and heal calculation. For example these can be used to implement immunities, or absorb effects
|
|
|
|
by modifying their damage values in aura callbacks.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Eventually I'll create a separate repository with a few examples/demos, but for now you can check the game
|
|
|
|
I've been working on for examples.
|
|
|
|
|
|
|
|
For 3d:
|
|
|
|
https://github.com/Relintai/broken_seals.git
|
|
|
|
|
|
|
|
For 2d:
|
|
|
|
https://github.com/Relintai/broken_seals_2d.git
|
|
|
|
|
|
|
|
## Compiling
|
|
|
|
|
|
|
|
First make sure that you can compile godot. See the official docs: https://docs.godotengine.org/en/3.2/development/compiling/index.html
|
|
|
|
|
|
|
|
1. Clone the engine if you haven't already:
|
|
|
|
|
|
|
|
```git clone https://github.com/godotengine/godot.git godot```
|
|
|
|
|
|
|
|
2. go into the modules folder inside the engine's directory"
|
|
|
|
|
|
|
|
```cd godot```
|
|
|
|
```cd modules```
|
|
|
|
|
|
|
|
3. clone this repository
|
|
|
|
|
|
|
|
```git clone https://github.com/Relintai/entity_spell_system.git entity_spell_system```
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
(the folder needs to be named entity_spell_system!)
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
4. Go up one folder
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
```cd ..```
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
5. Compile godot.
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
For example:
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
```scons p=x11 t=release_debug tools=yes```
|
2019-11-22 00:55:01 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
## TODO
|
2019-11-27 11:28:09 +01:00
|
|
|
|
2020-04-08 03:24:48 +02:00
|
|
|
Add to readme:
|
|
|
|
Loot, Species, cds, categ cds, items (crafting etc), Xp,
|
|
|
|
levelling, Stats, drag and drop, talents, vendors, Skills,
|
|
|
|
Profiles, Projectiles, Singletons, Skeleton,
|
2020-04-18 14:31:36 +02:00
|
|
|
Global enums
|
|
|
|
resourcedb
|