From e65b2f4ecb62768d493c224d3782526409fd0524 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 12 Sep 2019 23:06:24 +0200 Subject: [PATCH] Added SpellCategory to Spell. Also removed the old commented out code from Spell. --- data/spell.cpp | 745 +------------------------------------------------ data/spell.h | 54 +--- 2 files changed, 16 insertions(+), 783 deletions(-) diff --git a/data/spell.cpp b/data/spell.cpp index 2747318..dbba2bb 100644 --- a/data/spell.cpp +++ b/data/spell.cpp @@ -16,6 +16,13 @@ void Spell::set_spell_type(int value) { _spell_type = value; } +SpellEnums::SpellCategory Spell::get_spell_category() { + return _spell_category; +} +void Spell::set_spell_category(SpellEnums::SpellCategory value) { + _spell_category = value; +} + bool Spell::get_hide_from_actionbar() { return _hide_from_actionbar; } @@ -708,6 +715,7 @@ Spell::Spell() { _spell_id = 1; _spell_type = SpellEnums::SPELL_TYPE_NONE; + _spell_category = SpellEnums::SPELL_CATEGORY_NORMAL; _hide_from_actionbar = false; @@ -853,6 +861,10 @@ void Spell::_bind_methods() { ClassDB::bind_method(D_METHOD("set_spell_type", "value"), &Spell::set_spell_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "spell_type", PROPERTY_HINT_FLAGS, SpellEnums::BINDING_STRING_SPELL_TYPES), "set_spell_type", "get_spell_type"); + ClassDB::bind_method(D_METHOD("get_spell_category"), &Spell::get_spell_category); + ClassDB::bind_method(D_METHOD("set_spell_category", "value"), &Spell::set_spell_category); + ADD_PROPERTY(PropertyInfo(Variant::INT, "spell_category", PROPERTY_HINT_ENUM, SpellEnums::BINDING_STRING_SPELL_CATEGORY), "set_spell_category", "get_spell_category"); + ClassDB::bind_method(D_METHOD("get_hide_from_actionbar"), &Spell::get_hide_from_actionbar); ClassDB::bind_method(D_METHOD("set_hide_from_actionbar", "value"), &Spell::set_hide_from_actionbar); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_from_actionbar"), "set_hide_from_actionbar", "get_hide_from_actionbar"); @@ -1128,736 +1140,3 @@ void Spell::_bind_methods() { BIND_ENUM_CONSTANT(SPELL_PROJECTILE_TYPE_STRAIGHT); BIND_ENUM_CONSTANT(SPELL_PROJECTILE_TYPE_STATIONARY); } - -//// SpellScript Old - -/* -void Spell::TriggerGlobalCooldown(Entity* player) -{ - player->Stats->TriggerGlobalCooldown(); -} - -bool Spell::IsCasting(Entity* player) -{ - return player->SpellCastData->SCasting; -} - -bool Spell::HasClobalCooldown(Entity* player) -{ - return player->Stats->SHasGlobalCooldown; -} - -bool Spell::IsStunned(Entity* player) -{ - return player->StateComponent->SHasState(StateData::StateType::TYPE_STUN); -} - -bool Spell::HasState(StateData::StateType state, Entity* player) -{ - return player->StateComponent->SHasState(state); -} - -int Spell::GetId(Entity* spell) -{ - return spell->GetComponent()->SpellID; -} - -bool Spell::IsSpellOnCooldown(int spellId, Entity* player) -{ - PlayerSpellDataComponent* playerSpellDataComponent = player->PlayerSpellDataComponent; - for (int i = 0; i < playerSpellDataComponent->SSpellData->Count; i += 1) { - if (playerSpellDataComponent->SSpellData->GetData(i)->SpellId == spellId) { - return true; - } - } - return false; -} - -void Spell::ApplyAura(int auraId, Entity* caster, float spellScale) -{ - (AuraScript*)(Auras::Instance->GetData(auraId)->AuraScript)->Apply(caster, caster, spellScale); -} - -void Spell::ApplyAura(int auraId, Entity* caster, Entity* target, float spellScale) -{ - (AuraScript*)(Auras::Instance->GetData(auraId)->AuraScript)->Apply(caster, target, spellScale); -} - -void Spell::RemoveAura(int auraId, Entity* caster) -{ - (AuraScript*)(Auras::Instance->GetData(auraId)->AuraScript)->RemoveAura(caster); -} - -void Spell::AddCooldown(Entity* player, int spellId, float cooldown) -{ - PlayerSpellDataComponent* arg_10_0 = player->PlayerSpellDataComponent; - PlayerSpellCooldownData* psd = new PlayerSpellCooldownData(spellId, cooldown, cooldown); - arg_10_0->AddSSpellData(psd); -} - -void Spell::DoStartCasting(Entity* player, int spellId, String* spellName, float castTime, bool addMoveHook, float spellScale) -{ - player->SpellCastData->StartCasting(spellId, spellName, castTime, spellScale); - if (addMoveHook) { - OnPlayerMoveCallbackComponent* expr_1B = player->Opmcc; - expr_1B->RegisterSOnPlayerMove(new BaseOnPlayerMoveCallbackComponent::OnPlayerMoved(OnPlayerMove), spellId); - expr_1B->ServerCallbackAdded(); - } -} - -void Spell::DoCastFail(Entity* player, bool removeHook) -{ - player->SpellCastData->SCastFailed(); - if (removeHook) { - player->Opmcc->RemoveSOnPlayerMove(new BaseOnPlayerMoveCallbackComponent::OnPlayerMoved(OnPlayerMove), spellId); - } - CastingFailed(player); -} - -void Spell::AddOnMoveHook(Entity* player) -{ - OnPlayerMoveCallbackComponent* expr_06 = player->Opmcc; - expr_06->RegisterSOnPlayerMove(new BaseOnPlayerMoveCallbackComponent::OnPlayerMoved(OnPlayerMove), spellId); - expr_06->ServerCallbackAdded(); -} - -void Spell::RemoveOnMoveHook(Entity* player) -{ - player->Opmcc->RemoveSOnPlayerMove(new BaseOnPlayerMoveCallbackComponent::OnPlayerMoved(OnPlayerMove), spellId); -} -Entity* Spell::GetTarget(Entity* player) -{ - return player->TargetComponent->STarget; -} - -void Spell::DealDamage(Entity* caster, Entity* target, int damage) -{ - if (target != null) { - damagePipelineData->Set(damage, false, spell->GetSpellType, caster, target, spell->gameObject); - AuraComponent* auraComponent = target->AuraComponent; - auraComponent->OnHit(caster, target, spell, damagePipelineData->Damage); - auraComponent->POnBeforeDamage(damagePipelineData); - if (damagePipelineData->Damage == 0) { - return; - } - target->Stats->TakeDamage(damagePipelineData->Damage, false, caster); - auraComponent->OnDamageReceive(caster, target, spell, damagePipelineData->Damage); - } -} - -void Spell::DealDamage(Entity* caster, Entity* target, float spellScale) -{ - int num = UnityEngine::Random::Range(spell->DamageMin, spell->DamageMax); - if (checkParry(caster, target)) { - return; - } - PlayerData* playerData = caster->PlayerData; - num = (int)(((float)(num) * spell->GetDamageScaleForLevel(playerData->Level)) * spellScale); - Stats* stats = caster->Stats; - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - PercentStat* sMeleeDamage = stats->SMeleeDamage; - num = (int)((float)(num) * (sMeleeDamage->ModPercent / (float)100)); - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - PercentStat* sSpellDamage = stats->SSpellDamage; - num = (int)((float)(num) * (sSpellDamage->ModPercent / (float)100)); - } - } - float num2 = (float)0; - float num3 = (float)0; - bool flag = false; - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - num2 = stats->SMeleeCrit->ModPercent; - num3 = stats->SMeleeCritBonus->ModPercent; - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - num2 = stats->SSpellCrit->ModPercent; - num3 = stats->SSpellCritBonus->ModPercent; - } - } - num2 /= (float)100; - if (UnityEngine::Random::value <= num2) { - flag = true; - } - if (flag) { - num += (int)((float)(num) * (num3 / (float)100)); - } - if (target != null) { - Stats* stats2 = target->Stats; - num = (int)((float)(num) * (((float)100 - stats2->SDamageReduction->ModPercent) / (float)100)); - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - num = (int)((float)(num) * (((float)100 - stats2->SMeleeDamageReduction->ModPercent) / (float)100)); - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - num = (int)((float)(num) * (((float)100 - stats2->SSpellDamageReduction->ModPercent) / (float)100)); - } - } - num = (int)((float)(num) * (stats2->SDamageTaken->ModPercent / (float)100)); - damagePipelineData->Set(num, flag, spell->GetSpellType, caster, target, spell->gameObject); - AuraComponent* auraComponent = target->AuraComponent; - auraComponent->OnHit(caster, target, spell, damagePipelineData->Damage); - auraComponent->POnBeforeDamage(damagePipelineData); - if (damagePipelineData->Damage == 0) { - return; - } - stats2->TakeDamage(damagePipelineData->Damage, flag, caster); - auraComponent->OnDamageReceive(caster, target, spell, damagePipelineData->Damage); - } -} - -void Spell::VashDealDamage(Entity* caster, Entity* target, bool increased, float spellScale) -{ - int num = UnityEngine::Random::Range(spell->DamageMin, spell->DamageMax); - PlayerData* playerData = caster->PlayerData; - num = (int)(((float)(num) * spell->GetDamageScaleForLevel(playerData->Level)) * spellScale); - Stats* stats = caster->Stats; - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - PercentStat* sMeleeDamage = stats->SMeleeDamage; - num = (int)((float)(num) * (sMeleeDamage->ModPercent / (float)100)); - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - PercentStat* sSpellDamage = stats->SSpellDamage; - num = (int)((float)(num) * (sSpellDamage->ModPercent / (float)100)); - } - } - float num2 = (float)0; - float num3 = (float)0; - bool flag = false; - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - num2 = stats->SMeleeCrit->ModPercent; - num3 = stats->SMeleeCritBonus->ModPercent; - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - num2 = stats->SSpellCrit->ModPercent; - num3 = stats->SSpellCritBonus->ModPercent; - } - } - num2 /= (float)100; - if (UnityEngine::Random::value <= num2) { - flag = true; - } - if (flag) { - num += (int)((float)(num) * (num3 / (float)100)); - } - if (increased) { - num = (int)((float)(num) * (float)1.4); - } - if (target != null) { - Stats* stats2 = target->Stats; - num = (int)((float)(num) * (((float)100 - stats2->SDamageReduction->ModPercent) / (float)100)); - if (spell->GetSpellType == SpellType::TYPE_MELEE) { - num = (int)((float)(num) * (((float)100 - stats2->SMeleeDamageReduction->ModPercent) / (float)100)); - } - else { - if (spell->GetSpellType == SpellType::TYPE_MAGIC) { - num = (int)((float)(num) * (((float)100 - stats2->SSpellDamageReduction->ModPercent) / (float)100)); - } - } - num = (int)((float)(num) * (stats2->SDamageTaken->ModPercent / (float)100)); - damagePipelineData->Set(num, flag, spell->GetSpellType, caster, target, spell->gameObject); - AuraComponent* auraComponent = target->AuraComponent; - auraComponent->OnHit(caster, target, spell, damagePipelineData->Damage); - auraComponent->POnBeforeDamage(damagePipelineData); - if (damagePipelineData->Damage == 0) { - return; - } - stats2->TakeDamage(damagePipelineData->Damage, flag, caster); - auraComponent->OnDamageReceive(caster, target, spell, damagePipelineData->Damage); - } -} - -void Spell::Heal(Entity* caster, Entity* target, float spellScale) -{ - int num = UnityEngine::Random::Range(spell->SpellHealData->HealMin, spell->SpellHealData->HealMax); - PlayerData* playerData = caster->PlayerData; - num = (int)(((float)(num) * spell->GetHealScaleForLevel(playerData->Level)) * spellScale); - caster->Stats->TakeHeal(num, false, caster); -} - -void Spell::Heal(Entity* caster, Entity* target, int heal) -{ - caster->Stats->TakeHeal(heal, false, caster); -} - -bool Spell::checkParry(Entity* caster, Entity* target) -{ - if (spell->GetSpellType != SpellType::TYPE_MELEE) { - return false; - } - Stat* sParry = target->Stats->SParry; - return (!sParry->Disabled && ((UnityEngine::Random::value * (float)100) <= sParry->ModPercent)) && (Vector3::Angle(caster->transform->forward, target->transform->forward) > (float)90); -} - -WorldSpell* Spell::SpawnProjectile(Entity* caster, Entity* target, float spellScale) -{ - SpellProjectileData* spellProjectileData = spell->SpellProjectileData; - GameObject* arg_B7_0 = UnityEngine::Object::Instantiate(spellProjectileData->Projectile); - PlayerFacingComponent* playerFacingComponent = caster->PlayerFacingComponent; - tmp3->Set(playerFacingComponent->SFacing->x, playerFacingComponent->SFacing->y, playerFacingComponent->SFacing->z); - tmp3->Normalize(); - tmp2->Set(caster->transform->position->x, caster->transform->position->y + (float)1.2, caster->transform->position->z); - tmp2 += tmp3 * (float)0.4; - arg_B7_0->transform->position = tmp2; - arg_B7_0->transform->rotation = caster->transform->rotation; - WorldSpell* expr_E3 = arg_B7_0->GetComponent(); - expr_E3->SetData(spellProjectileData, caster, spell, spellScale, tmp3, null); - return expr_E3; -} - -bool Spell::isInRange(Entity* target, Entity* player) -{ - SpellRangeData* spellRangeData = spell->SpellRangeData; - tmp2->Set(target->transform->position->x, target->transform->position->y, target->transform->position->z); - tmp2 -= player->transform->position; - return tmp2->magnitude < (spellRangeData->Range + ((float)2 * PLAYER_HIT_RADIUS)); -} - -bool Spell::CanCast(Entity* caster, int skipCheck) -{ - return ((((!IsCasting(caster) && (!spell->HasGlobalCooldown || !HasClobalCooldown(caster))) && !IsSpellOnCooldown(spellId, caster)) && (((skipCheck & 1) == 1) || !IsStunned(caster))) && (((skipCheck & 2) == 2) || !HasState(StateData::StateType::TYPE_ROOT, caster))) && (((skipCheck & 4) == 4) || !HasState(StateData::StateType::TYPE_FROZEN, caster)); -} - -bool Spell::CanCastTarget(Entity* caster, int skipCheck) -{ - return (((!IsCasting(caster) && (!spell->HasGlobalCooldown || !HasClobalCooldown(caster))) && !IsSpellOnCooldown(spellId, caster)) && (((skipCheck & 1) == 1) || !IsStunned(caster))) && !GetTarget(caster) == null; -} - -bool Spell::CanCastTargetRange(Entity* caster, int skipCheck) -{ - if (IsCasting(caster)) { - return false; - } - if (spell->HasGlobalCooldown && HasClobalCooldown(caster)) { - return false; - } - if (IsSpellOnCooldown(spellId, caster)) { - return false; - } - if (((skipCheck & 1) != 1) && IsStunned(caster)) { - return false; - } - Entity* target = GetTarget(caster); - return !target == null && isInRange(target, caster); -} - -bool Spell::SpellCostCheckAndRemove(Entity* caster) -{ - if ((spell->CostType == PlayerResourceTypes::None) && (spell->ItemCost == 0)) { - return true; - } - Inventory* inventory = null; - if (spell->ItemCost != 0) { - inventory = caster->Inventory; - if (!inventory->SHasItem(spell->ItemCost, 1)) { - return false; - } - } - if (spell->CostType != PlayerResourceTypes::None) { - PlayerResource* playerResource = caster->PlayerResourceComponent->SGetPlayerResource(spell->CostType); - if (playerResource == null) { - return false; - } - if (playerResource->Current < spell->CostResource) { - return false; - } - PlayerResource* expr_87 = playerResource; - expr_87->Current -= spell->CostResource; - } - if (spell->ItemCost != 0) { - inventory->STryToRemoveItem(spell->ItemCost, 1); - } - return true; -} - -bool Spell::SpellCostCheck(Entity* caster) -{ - if ((spell->CostType == PlayerResourceTypes::None) && (spell->ItemCost == 0)) { - return true; - } - if ((spell->ItemCost != 0) && !caster->Inventory->SHasItem(spell->ItemCost, 1)) { - return false; - } - if (spell->CostType != PlayerResourceTypes::None) { - PlayerResource* playerResource = caster->PlayerResourceComponent->SGetPlayerResource(spell->CostType); - if (playerResource == null) { - return false; - } - if (playerResource->Current < spell->CostResource) { - return false; - } - } - return true; -} - -void Spell::SpellResourceGive(Entity* caster) -{ - if (spell->GiveResourceType == PlayerResourceTypes::None) { - return; - } - PlayerResource* playerResource = caster->PlayerResourceComponent->SGetPlayerResource(spell->GiveResourceType); - if (playerResource == null) { - return; - } - if (playerResource->Current == playerResource->Max) { - return; - } - PlayerResource* expr_39 = playerResource; - expr_39->Current += spell->GiveResource; -} - -void Spell::AddSpellCastEffect(Entity* caster) -{ - SpellCastEffectData* spellCastEffectData = spell->SpellCastEffectData; - if (spellCastEffectData->Effect == null) { - return; - } - CharacterEffectPointGetter* component = caster->GetComponent(); - if (component != null) { - component->AddSpellCastEffect(spellCastEffectData->Effect); - } -} - -void Spell::RemoveSpellCastEffects(Entity* caster) -{ - CharacterEffectPointGetter* component = caster->GetComponent(); - if (component != null) { - component->RemoveSpellCastEffects(); - } -} - -void Spell::AddEffect(Entity* player, GameObject* effectPrefab, EffectPoints bodyPart, Quaternion* rotation) -{ - Transform* effectPoint = player->GetComponent()->GetEffectPoint(bodyPart); - if (effectPoint == null) { - return; - } - GameObject* expr_28 = UnityEngine::Object::Instantiate(effectPrefab, Vector3::zero, Quaternion::identity, effectPoint); - expr_28->AddComponent()->Id = spellId; - expr_28->transform->localRotation = rotation; - expr_28->transform->localPosition = Vector3::zero; -} - -void Spell::AddWorldEffect(Entity* location, GameObject* effectPrefab, Vector3* offset, Quaternion* rotation) -{ - UnityEngine::Object::Instantiate(effectPrefab, *(location->transform->position) + *offset, location->transform->rotation)->AddComponent()->Id = spellId; -} - -void Spell::RemoveEffect(Entity* player, EffectPoints bodyPart) -{ - Transform* effectPoint = player->GetComponent()->GetEffectPoint(bodyPart); - if (effectPoint == null) { - return; - } - for (int i = 0; i < effectPoint->childCount; i += 1) { - Transform* child = effectPoint->GetChild(i); - EffectIdAttribute* component = child->GetComponent(); - if (!component == null && (component->Id == spellId)) { - child->SetParent(null); - UnityEngine::Object::Destroy(child->gameObject); - return; - } - } -} - -String* Spell::StringifyCooldown(float cooldown) -{ - if (cooldown < (float)60) { - return BOX((int)(cooldown)) + *(new String(" sec")); - } - cooldown /= (float)60; - int num = (int)(cooldown); - float num2 = (float)(num); - if (((double)(cooldown) > ((double)(num2) - 0.05)) && ((double)(cooldown) < ((double)(num2) + 0.05))) { - return BOX(num) + *(new String(" min")); - } - return String::Format(new String("{0:0.0} min"), BOX(cooldown)); -} - -String* Spell::GetName() -{ - return spell->SpellName; -} - -String* Spell::GetDescription(int level) -{ - if (spell->SpellDescription == *(new String(""))) { - return new String(""); - } - String* arg_A6_0 = spell->SpellDescription; - Array* expr_2E = new Array(4); - expr_2E->SetData(0, BOX((int)((float)(spell->DamageMin) * spell->GetDamageScaleForLevel(level)))); - expr_2E->SetData(1, BOX((int)((float)(spell->DamageMax) * spell->GetDamageScaleForLevel(level)))); - expr_2E->SetData(2, StringifyCooldown(spell->Cooldown)); - expr_2E->SetData(3, new String(spell->CastTime) + *(new String(" sec"))); - return String::Format(arg_A6_0, expr_2E); -} - -void Spell::SpellCastSuccess(Entity* caster) -{ - caster->SpellMgrComponent->SSendSpellCastSuccess(spellId); -} - -void Spell::PlaySound(String* sound) -{ - SoundMgr::PlaySoundAndForget(sound); -} - -void Spell::PlayStandardSpellCastFinish() -{ - PlaySound(new String("SpellEnd")); -} - -void Spell::PlayStandardSpellCastFinish(Entity* caster) -{ - LocalPlayerAnimationController* component = caster->GetComponent(); - if (component != null) { - component->TriggerAttack(); - AnimStop(caster); - } - else { - NetworkedPlayerAnimationController* component2 = caster->GetComponent(); - if (component2 != null) { - component2->TriggerAttack(); - AnimStop(caster); - } - } - PlaySound(new String("SpellEnd")); -} - -void Spell::PlayStandardIceArcherAttackSpellCastFinish(Entity* caster) -{ - LocalPlayerAnimationController* component = caster->GetComponent(); - if (component != null) { - component->TriggerAttack(); - AnimStop(caster); - } - else { - NetworkedPlayerAnimationController* component2 = caster->GetComponent(); - if (component2 != null) { - component2->TriggerAttack(); - AnimStop(caster); - } - } - PlaySound(new String("SpellEnd")); -} - -void Spell::PlayStandardBerserkerAttackSpellCastFinish(Entity* caster) -{ - LocalPlayerAnimationController* component = caster->GetComponent(); - if (component != null) { - component->TriggerAttack(); - AnimStop(caster); - } - else { - NetworkedPlayerAnimationController* component2 = caster->GetComponent(); - if (component2 != null) { - component2->TriggerAttack(); - AnimStop(caster); - } - } - PlaySound(new String("MHit")); -} - -void Spell::AnimStop(Entity* player) -{ - bool arg_0A_0 = BSSettings::Getinstance()->AnimStopEnabled; -}*/ - -//Generic - -/* - -GenericSpell::GenericSpell(Spell* spell) : Spell(spell){ - if (!Mathf::Approximately(spell->CastTime, (float)0)){ - hasCastTime = true; - } - if (!Mathf::Approximately(spell->Cooldown, (float)0)) { - hasCooldown = true; - } - if ((spell->DamageMin > 0) && (spell->DamageMax > 0)) { - damage = true; - } -} -void GenericSpell::StartCasting(WorldEntity* caster, float spellScale) -{ - if ((spell->GenericSpellData->NeedsTarget || damage) && !hasCastTime) { - if (!Spell::CanCastTarget(caster, 0)) { - return; - } - } - else { - if (!Spell::CanCast(caster, 0)) { - return; - } - } - WorldEntity* worldEntity = null; - if (spell->GenericSpellData->NeedsTarget || damage) { - worldEntity = Spell::GetTarget(caster); - } - if (!hasCastTime) { - if (spell->SpellRangeData->Enabled && !Spell::isInRange(caster, worldEntity)) { - return; - } - HandleSpellEffect(caster, worldEntity, spellScale); - return; - } - else { - if (!Spell::SpellCostCheck(caster)) { - return; - } - Spell::DoStartCasting(caster, spellId, spell->SpellName, spell->CastTime, !spell->GenericSpellData->CanMoveWhileCasting, spellScale); - return; - } -} -void GenericSpell::CastingFinished(WorldEntity* caster, float spellScale) -{ - WorldEntity* worldEntity = null; - if (spell->GenericSpellData->NeedsTarget || damage) { - worldEntity = Spell::GetTarget(caster); - } - if (spell->GenericSpellData->NeedsTarget && (worldEntity == null)) { - return; - } - if (spell->SpellRangeData->Enabled && !Spell::isInRange(caster, worldEntity)) { - return; - } - HandleSpellEffect(caster, worldEntity, spellScale); - if (hasCastTime && !spell->GenericSpellData->CanMoveWhileCasting) { - Spell::RemoveOnMoveHook(caster); - } -} -void GenericSpell::SpellHit(WorldEntity* caster, WorldEntity* target, WorldSpell* worldSpell, Spell* spellGO, float spellScale) -{ - if (target->CompareTag(new String("Player"))) { - if (damage) { - Spell::DealDamage(caster, target, spellScale); - } - if (spell->SpellHealData->Enabled) { - Spell::Heal(caster, caster, spellScale); - } - if (spell->CasterAuraApply != 0) { - Spell::ApplyAura(spell->CasterAuraApply, caster, spellScale); - } - if (spell->CasterAuraApply2 != 0) { - Spell::ApplyAura(spell->CasterAuraApply2, caster, spellScale); - } - if (spell->TargetAuraApply != 0) { - Spell::ApplyAura(spell->TargetAuraApply, target, spellScale); - } - if (spell->TargetAuraApply2 != 0) { - Spell::ApplyAura(spell->TargetAuraApply2, target, spellScale); - } - HandleSpellStatValueMod(caster); - } - if (spell->SpellProjectileData->DestroyOnImpact) { - worldSpell->Destroy(); - } -} -void GenericSpell::OnPlayerMove(Entity* caster) -{ - Spell::DoCastFail((WorldEntity*)(caster), true); -} -void GenericSpell::HandleSpellEffect(WorldEntity* caster, WorldEntity* target, float spellScale) -{ - if (!Spell::SpellCostCheckAndRemove(caster)) { - return; - } - if (!spell->SpellProjectileData->Enabled) { - if (damage) { - Spell::DealDamage(caster, target, spellScale); - } - if (spell->SpellHealData->Enabled) { - Spell::Heal(caster, caster, spellScale); - } - if (spell->CasterAuraApply != 0) { - Spell::ApplyAura(spell->CasterAuraApply, caster, spellScale); - } - if (spell->CasterAuraApply2 != 0) { - Spell::ApplyAura(spell->CasterAuraApply2, caster, spellScale); - } - if (spell->TargetAuraApply != 0) { - Spell::ApplyAura(spell->TargetAuraApply, caster, target, spellScale); - } - if (spell->TargetAuraApply2 != 0) { - Spell::ApplyAura(spell->TargetAuraApply2, caster, target, spellScale); - } - HandleSpellStatValueMod(caster); - } - else { - Spell::SpawnProjectile(caster, target, spellScale); - } - if (spell->HasGlobalCooldown && !hasCastTime) { - Spell::TriggerGlobalCooldown(caster); - } - Spell::SpellResourceGive(caster); - if (hasCooldown) { - Spell::AddCooldown(caster, spellId, spell->Cooldown); - } - Spell::SpellCastSuccess(caster); -} -void GenericSpell::HandleSpellStatValueMod(WorldEntity* caster) -{ - if (!spell->SpellStatValueModData->Enabled) { - return; - } - Stats* stats = caster->Stats; - for (int i = 0; i < spell->SpellStatValueModData->StatValueMods->Count; i += 1) { - SpellStatValueModAttributeHelper* spellStatValueModAttributeHelper = spell->SpellStatValueModData->StatValueMods->GetData(i); - ValueStat* valueStat = (ValueStat*)(stats->GetSStatFromId(spellStatValueModAttributeHelper->Stat)); - if (spellStatValueModAttributeHelper->Stat != 0) { - if (spellStatValueModAttributeHelper->HasValueMod) { - ValueStat* expr_5B = valueStat; - expr_5B->Current += spellStatValueModAttributeHelper->GiveValue; - } - if (spellStatValueModAttributeHelper->HasPercentMod) { - ValueStat* expr_79 = valueStat; - expr_79->Current += valueStat->Max * (spellStatValueModAttributeHelper->GivePercentValue / (float)100); - } - } - else { - if (spellStatValueModAttributeHelper->HasValueMod) { - if (spellStatValueModAttributeHelper->GiveValue > (float)0) { - stats->TakeHeal((int)(spellStatValueModAttributeHelper->GiveValue), false, caster); - } - else { - stats->TakeDamage((int)(spellStatValueModAttributeHelper->GiveValue), false, caster); - } - } - if (spellStatValueModAttributeHelper->HasPercentMod) { - if (spellStatValueModAttributeHelper->GivePercentValue > (float)0) { - stats->TakeHeal((int)(valueStat->Max * (spellStatValueModAttributeHelper->GivePercentValue / (float)100)), false, caster); - } - else { - stats->TakeDamage((int)(valueStat->Max * (spellStatValueModAttributeHelper->GivePercentValue / (float)100)), false, caster); - } - } - } - } -} -void GenericSpell::COnSpellCastSuccess(WorldEntity* player) -{ - if (!hasCastTime && damage) { - Spell::PlayStandardSpellCastFinish(player); - return; - } - Spell::PlayStandardSpellCastFinish(); -} -void GenericSpell::COnSpellCastStarted(WorldEntity* player) -{ - if (spell->SpellCastEffectData->Enabled) { - Spell::AddSpellCastEffect(player); - } -} -void GenericSpell::COnSpellCastEnded(WorldEntity* player) -{ - if (spell->SpellCastEffectData->Enabled) { - Spell::RemoveSpellCastEffects(player); - } -} - -*/ diff --git a/data/spell.h b/data/spell.h index fcb5b0a..c442185 100644 --- a/data/spell.h +++ b/data/spell.h @@ -88,6 +88,9 @@ public: int get_spell_type(); void set_spell_type(int value); + SpellEnums::SpellCategory get_spell_category(); + void set_spell_category(SpellEnums::SpellCategory value); + bool get_hide_from_actionbar(); void set_hide_from_actionbar(bool value); @@ -303,56 +306,6 @@ public: String get_name(); String get_description(int level); - /* - void TriggerGlobalCooldown(Entity *player); - bool IsCasting(Entity *player); - bool HasClobalCooldown(Entity *player); - bool IsStunned(Entity *player); - bool HasState(StateData::StateType state, Entity *player); - int GetId(Entity *spell); - bool IsSpellOnCooldown(int spellId, Entity *player); - void ApplyAura(int auraId, Entity *caster, float spellScale); - void ApplyAura(int auraId, Entity *caster, Entity *target, float spellScale); - void RemoveAura(int auraId, Entity *caster); - void AddCooldown(Entity *player, int spellId, float cooldown); - void DoStartCasting(Entity *player, int spellId, String spellName, float castTime, bool addMoveHook, float spellScale); - void DoCastFail(Entity *player, bool removeHook); - void AddOnMoveHook(Entity *player); - void RemoveOnMoveHook(Entity *player); - Entity *GetTarget(Entity *player); - void DealDamage(Entity *caster, Entity *target, int damage); - void DealDamage(Entity *caster, Entity *target, float spellScale); - void VashDealDamage(Entity *caster, Entity *target, bool increased, float spellScale); - void Heal(Entity *caster, Entity *target, float spellScale); - void Heal(Entity *caster, Entity *target, int heal); - bool checkParry(Entity *caster, Entity *target); - - - Node *OldLaunchFollowProjectile(Node *effect, Entity *caster, Entity *target, float speed, float spellScale, float time = (float)0); - Node *OldLaunchStraightProjectile(Node *effect, Entity *caster, float speed, float time, float range, float spellScale); - Node *OldLaunchProjectile(Entity *caster, Entity *target, float spellScale); - WorldSpell *SpawnProjectile(Entity *caster, Entity *target, float spellScale); - bool isInRange(Entity *target, Entity *player); - bool CanCast(Entity *caster, int skipCheck = 0); - bool CanCastTarget(Entity *caster, int skipCheck = 0); - bool CanCastTargetRange(Entity *caster, int skipCheck = 0); - bool SpellCostCheckAndRemove(Entity *caster); - bool SpellCostCheck(Entity *caster); - void SpellResourceGive(Entity *caster); - void AddSpellCastEffect(Entity *caster); - void RemoveSpellCastEffects(Entity *caster); - void AddEffect(Entity *player, Node *effectPrefab, EffectPoints bodyPart, Quaternion *rotation =); - void AddWorldEffect(Entity *location, Node *effectPrefab, Vector3 *offset =, Quaternion *rotation =); - void RemoveEffect(Entity *player, EffectPoints bodyPart); - String StringifyCooldown(float cooldown); - void SpellCastSuccess(Entity *caster); - void PlaySound(String sound); - void PlayStandardSpellCastFinish(); - void PlayStandardSpellCastFinish(Entity *caster); - void PlayStandardIceArcherAttackSpellCastFinish(Entity *caster); - void PlayStandardBerserkerAttackSpellCastFinish(Entity *caster); - void AnimStop(Entity *player);*/ - Spell(); ~Spell(); @@ -362,6 +315,7 @@ protected: private: int _spell_id; int _spell_type; + SpellEnums::SpellCategory _spell_category; bool _hide_from_actionbar; float _cooldown;