diff --git a/SCsub b/SCsub index cf55aa4..8940bcc 100644 --- a/SCsub +++ b/SCsub @@ -102,6 +102,8 @@ sources = [ "formations/ai_formation.cpp", + "projectiles/3d/spell_follow_projectile_3d.cpp", + "profiles/input/input_profile_modifier.cpp", "profiles/input/input_profile_modifier_entry.cpp", "profiles/input/input_profile.cpp", diff --git a/config.py b/config.py index 13cdd77..09cf965 100644 --- a/config.py +++ b/config.py @@ -97,8 +97,7 @@ def get_doc_classes(): "Cooldown", "EntityCreateInfo", - "WorldSpellData", - "WorldSpell", + "SpellFollowProjectile3D", "EntityDataManager", diff --git a/data/spells/spell.cpp b/data/spells/spell.cpp index 7066ae2..6066889 100644 --- a/data/spells/spell.cpp +++ b/data/spells/spell.cpp @@ -319,39 +319,39 @@ void Spell::set_cast_time(const float value) { _cast_time = value; } -bool Spell::delay_get_use_time() const { - return _delay_use_time; +bool Spell::projectile_get_use_time() const { + return _projectile_use_time; } -void Spell::delay_set_use_time(const bool value) { - _delay_use_time = value; +void Spell::projectile_set_use_time(const bool value) { + _projectile_use_time = value; } -float Spell::delay_get_time() const { - return _delay_time; +float Spell::projectile_get_time() const { + return _projectile_time; } -void Spell::delay_set_time(const float value) { - _delay_time = value; +void Spell::projectile_set_time(const float value) { + _projectile_time = value; } -bool Spell::delay_get_use_speed() const { - return _delay_use_speed; +bool Spell::projectile_get_use_speed() const { + return _projectile_use_speed; } -void Spell::delay_set_use_speed(const bool value) { - _delay_use_speed = value; +void Spell::projectile_set_use_speed(const bool value) { + _projectile_use_speed = value; } -float Spell::delay_get_speed() const { - return _delay_speed; +float Spell::projectile_get_speed() const { + return _projectile_speed; } -void Spell::delay_set_speed(const float value) { - _delay_speed = value; +void Spell::projectile_set_speed(const float value) { + _projectile_speed = value; } -Ref Spell::delay_get_scene() const { - return _delay_scene; +Ref Spell::projectile_get_scene() const { + return _projectile_scene; } -void Spell::delay_set_scene(const Ref &value) { - _delay_scene = value; +void Spell::projectile_set_scene(const Ref &value) { + _projectile_scene = value; } bool Spell::get_damage_enabled() const { @@ -883,10 +883,10 @@ Spell::Spell() { _training_cost = 0; _training_required_skill_level = 0; - _delay_use_time = false; - _delay_time = 0; - _delay_use_speed = false; - _delay_speed = 0; + _projectile_use_time = false; + _projectile_time = 0; + _projectile_use_speed = false; + _projectile_speed = 0; } Spell::~Spell() { @@ -908,7 +908,7 @@ Spell::~Spell() { _training_required_spell.unref(); _training_required_skill.unref(); - _delay_scene.unref(); + _projectile_scene.unref(); } void Spell::_sstart_casting(Ref info) { @@ -998,18 +998,18 @@ void Spell::_handle_spell_heal(Ref data) { } void Spell::_handle_projectile(Ref info) { - /* - if (_world_spell_data.is_valid()) { - WorldSpell *ws = memnew(WorldSpell); + if (_projectile_scene.is_valid()) { + Node *projectile = _projectile_scene->instance(); Node *p = info->get_caster()->get_parent(); ERR_FAIL_COND(!ObjectDB::instance_validate(p)); - p->add_child(ws); - ws->send(_world_spell_data, info); + p->add_child(projectile); + + if (projectile->has_method("setup_projectile")) + projectile->call("setup_projectile", info); } - */ } void Spell::_handle_effect(Ref info) { @@ -1303,26 +1303,26 @@ void Spell::_bind_methods() { ClassDB::bind_method(D_METHOD("set_can_move_while_casting", "value"), &Spell::set_can_move_while_casting); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cast_can_move_while_casting"), "set_can_move_while_casting", "get_can_move_while_casting"); - ADD_GROUP("Delay", "delay"); - ClassDB::bind_method(D_METHOD("delay_get_use_time"), &Spell::delay_get_use_time); - ClassDB::bind_method(D_METHOD("delay_set_use_time", "value"), &Spell::delay_set_use_time); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "delay_use_time"), "delay_set_use_time", "delay_get_use_time"); + ADD_GROUP("Projectile", "projectile"); + ClassDB::bind_method(D_METHOD("projectile_get_use_time"), &Spell::projectile_get_use_time); + ClassDB::bind_method(D_METHOD("projectile_set_use_time", "value"), &Spell::projectile_set_use_time); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "projectile_use_time"), "projectile_set_use_time", "projectile_get_use_time"); - ClassDB::bind_method(D_METHOD("delay_get_time"), &Spell::delay_get_time); - ClassDB::bind_method(D_METHOD("delay_set_time", "value"), &Spell::delay_set_time); - ADD_PROPERTY(PropertyInfo(Variant::INT, "delay_time"), "delay_set_time", "delay_get_time"); + ClassDB::bind_method(D_METHOD("projectile_get_time"), &Spell::projectile_get_time); + ClassDB::bind_method(D_METHOD("projectile_set_time", "value"), &Spell::projectile_set_time); + ADD_PROPERTY(PropertyInfo(Variant::INT, "projectile_time"), "projectile_set_time", "projectile_get_time"); - ClassDB::bind_method(D_METHOD("delay_get_use_speed"), &Spell::delay_get_use_speed); - ClassDB::bind_method(D_METHOD("delay_set_use_speed", "value"), &Spell::delay_set_use_speed); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "delay_use_speed"), "delay_set_use_speed", "delay_get_use_speed"); + ClassDB::bind_method(D_METHOD("projectile_get_use_speed"), &Spell::projectile_get_use_speed); + ClassDB::bind_method(D_METHOD("projectile_set_use_speed", "value"), &Spell::projectile_set_use_speed); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "projectile_use_speed"), "projectile_set_use_speed", "projectile_get_use_speed"); - ClassDB::bind_method(D_METHOD("delay_get_speed"), &Spell::delay_get_speed); - ClassDB::bind_method(D_METHOD("delay_set_speed", "value"), &Spell::delay_set_speed); - ADD_PROPERTY(PropertyInfo(Variant::INT, "delay_speed"), "delay_set_speed", "delay_get_speed"); + ClassDB::bind_method(D_METHOD("projectile_get_speed"), &Spell::projectile_get_speed); + ClassDB::bind_method(D_METHOD("projectile_set_speed", "value"), &Spell::projectile_set_speed); + ADD_PROPERTY(PropertyInfo(Variant::INT, "projectile_speed"), "projectile_set_speed", "projectile_get_speed"); - ClassDB::bind_method(D_METHOD("delay_get_scene"), &Spell::delay_get_scene); - ClassDB::bind_method(D_METHOD("delay_set_scene", "value"), &Spell::delay_set_scene); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "delay_scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "delay_set_scene", "delay_get_scene"); + ClassDB::bind_method(D_METHOD("projectile_get_scene"), &Spell::projectile_get_scene); + ClassDB::bind_method(D_METHOD("projectile_set_scene", "value"), &Spell::projectile_set_scene); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "projectile_scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "projectile_set_scene", "projectile_get_scene"); ADD_GROUP("Damage", "damage"); ClassDB::bind_method(D_METHOD("get_damage_enabled"), &Spell::get_damage_enabled); diff --git a/data/spells/spell.h b/data/spells/spell.h index befe5ad..86d4db9 100644 --- a/data/spells/spell.h +++ b/data/spells/spell.h @@ -186,20 +186,20 @@ public: void set_cast_time(const float value); //Delay - bool delay_get_use_time() const; - void delay_set_use_time(const bool value); + bool projectile_get_use_time() const; + void projectile_set_use_time(const bool value); - float delay_get_time() const; - void delay_set_time(const float value); + float projectile_get_time() const; + void projectile_set_time(const float value); - bool delay_get_use_speed() const; - void delay_set_use_speed(const bool value); + bool projectile_get_use_speed() const; + void projectile_set_use_speed(const bool value); - float delay_get_speed() const; - void delay_set_speed(const float value); + float projectile_get_speed() const; + void projectile_set_speed(const float value); - Ref delay_get_scene() const; - void delay_set_scene(const Ref &value); + Ref projectile_get_scene() const; + void projectile_set_scene(const Ref &value); //Damage bool get_damage_enabled() const; @@ -398,11 +398,11 @@ private: float _range; //Delay - bool _delay_use_time; - float _delay_time; - bool _delay_use_speed; - float _delay_speed; - Ref _delay_scene; + bool _projectile_use_time; + float _projectile_time; + bool _projectile_use_speed; + float _projectile_speed; + Ref _projectile_scene; bool _damage_enabled; int _damage_type; diff --git a/projectiles/3d/spell_follow_projectile_3d.cpp b/projectiles/3d/spell_follow_projectile_3d.cpp new file mode 100644 index 0000000..4d414e6 --- /dev/null +++ b/projectiles/3d/spell_follow_projectile_3d.cpp @@ -0,0 +1,39 @@ +/* +Copyright (c) 2019-2020 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "spell_follow_projectile_3d.h" + +#include "../../infos/spell_cast_info.h" + +void SpellFollowProjectile3D::setup_projectile(Ref info) { + _info = info; +} + +SpellFollowProjectile3D::SpellFollowProjectile3D() { +} +SpellFollowProjectile3D::~SpellFollowProjectile3D() { + _info.unref(); +} + +void SpellFollowProjectile3D::_bind_methods() { + //ClassDB::bind_method(D_METHOD("setup_projectile", "info"), &SpellFollowProjectile3D::setup_projectile); +} diff --git a/projectiles/3d/spell_follow_projectile_3d.h b/projectiles/3d/spell_follow_projectile_3d.h new file mode 100644 index 0000000..8d580b1 --- /dev/null +++ b/projectiles/3d/spell_follow_projectile_3d.h @@ -0,0 +1,46 @@ +/* +Copyright (c) 2019-2020 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef SPELL_PROJECTILE_3D +#define SPELL_PROJECTILE_3D + +#include "scene/3d/spatial.h" + +class SpellCastInfo; + +class SpellFollowProjectile3D : public Spatial { + GDCLASS(SpellFollowProjectile3D, Spatial); + +public: + void setup_projectile(Ref info); + + SpellFollowProjectile3D(); + ~SpellFollowProjectile3D(); + +protected: + static void _bind_methods(); + +private: + Ref _info; +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index 988a77c..b88fc15 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -114,6 +114,8 @@ SOFTWARE. #include "data/spells/spell_effect_visual.h" #include "data/spells/spell_effect_visual_simple.h" +#include "projectiles/3d/spell_follow_projectile_3d.h" + #include "entities/ai/entity_ai.h" #include "formations/ai_formation.h" @@ -218,6 +220,7 @@ void register_entity_spell_system_types() { //UI ClassDB::register_class(); + //Skeleton ClassDB::register_class(); ClassDB::register_class(); @@ -235,6 +238,9 @@ void register_entity_spell_system_types() { ClassDB::register_class(); ClassDB::register_class(); + //Projectiles + ClassDB::register_class(); + //AI ClassDB::register_class();