예제 #1
0
        private void OnSpellLaunch(Unit caster, int spellId, SpellProcessingToken processingToken, Vector3 source)
        {
            if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo))
            {
                return;
            }

            if (spellSettingsByInfo.TryGetValue(spellInfo, out SpellSoundSettings spellSoundSettings))
            {
                spellSoundSettings.PlayAtPoint(spellInfo.HasAttribute(SpellCustomAttributes.LaunchSourceIsExplicit) ?
                                               source : caster.Position, SpellSoundEntry.UsageType.Cast);
            }
        }
예제 #2
0
        private void OnSpellLaunch(Unit caster, int spellId, SpellProcessingToken processingToken)
        {
            if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo))
            {
                return;
            }

            if (!unitRendererController.TryFind(caster.Id, out UnitRenderer casterRenderer))
            {
                return;
            }

            if (!spellInfo.HasAttribute(SpellCustomAttributes.CastWithoutAnimation))
            {
                casterRenderer.TriggerInstantCast();
            }

            if (!SpellVisuals.TryGetValue(spellId, out SpellVisualsInfo spellVisuals))
            {
                return;
            }

            if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Projectile, out EffectSpellSettings settings))
            {
                foreach (var entry in processingToken.ProcessingEntries)
                {
                    if (unitRendererController.TryFind(entry.Item1, out UnitRenderer targetRenderer))
                    {
                        spellVisualController.SpawnVisual(casterRenderer, targetRenderer, settings, processingToken.ServerFrame, entry.Item2);
                    }
                }
            }

            if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Cast, out EffectSpellSettings spellVisualEffect))
            {
                IEffectEntity effectEntity = spellVisualEffect.EffectSettings.PlayEffect(processingToken.Source + Vector3.up, caster.Rotation);
                if (effectEntity != null && !spellInfo.HasAttribute(SpellCustomAttributes.LaunchSourceIsExplicit))
                {
                    effectEntity.ApplyPositioning(casterRenderer.TagContainer, spellVisualEffect);
                }
            }

            if (spellInfo.ExplicitTargetType == SpellExplicitTargetType.Destination)
            {
                if (spellVisuals.VisualsByUsage.TryGetValue(EffectSpellSettings.UsageType.Destination, out EffectSpellSettings destinationEffect))
                {
                    destinationEffect.EffectSettings.PlayEffect(processingToken.Destination + Vector3.up, caster.Rotation);
                }
            }
        }
        internal void HandleLaunch(out bool isDelayed, out SpellProcessingToken processingToken)
        {
            isDelayed       = false;
            processingToken = null;

            foreach (SpellTargetEntry targetEntry in Entries)
            {
                // calculate hit result
                if (spell.OriginalCaster != null)
                {
                    targetEntry.MissCondition = spell.OriginalCaster.Spells.SpellHitResult(targetEntry.Target, spell.SpellInfo, spell.CanReflect);
                    if (targetEntry.MissCondition != SpellMissType.Immune)
                    {
                        targetEntry.MissCondition = SpellMissType.None;
                    }
                }
                else
                {
                    targetEntry.MissCondition = SpellMissType.Evade;
                }

                // calculate hit delay for spells with speed
                if (spell.SpellInfo.Speed > 0.0f && spell.Caster != targetEntry.Target)
                {
                    float distance = Mathf.Clamp(Vector3.Distance(spell.Caster.Position, targetEntry.Target.Position), StatUtils.DefaultCombatReach, float.MaxValue);
                    targetEntry.Delay = Mathf.FloorToInt(distance / spell.SpellInfo.Speed * 1000.0f);

                    if (processingToken == null)
                    {
                        processingToken = new SpellProcessingToken {
                            ServerFrame = BoltNetwork.ServerFrame
                        }
                    }
                    ;

                    processingToken.ProcessingEntries.Add((targetEntry.Target.Id, targetEntry.Delay));
                }
                else
                {
                    targetEntry.Delay = 0;
                }

                targetEntry.Crit = spell.Caster.Spells.IsSpellCrit(targetEntry.Target, spell.SpellInfo, spell.SchoolMask);

                isDelayed |= targetEntry.Delay > 0;
            }
        }
예제 #4
0
        private void OnServerSpellLaunch(Unit caster, SpellInfo spellInfo, SpellProcessingToken processingToken)
        {
            UnitSpellLaunchEvent unitCastEvent = UnitSpellLaunchEvent.Create(caster.BoltEntity, EntityTargets.Everyone);

            unitCastEvent.SpellId           = spellInfo.Id;
            unitCastEvent.ProcessingEntries = processingToken;
            unitCastEvent.Send();

            SpellCastRequestAnswerEvent spellCastAnswer = caster.IsController
                ? SpellCastRequestAnswerEvent.Create(GlobalTargets.OnlyServer, ReliabilityModes.ReliableOrdered)
                : SpellCastRequestAnswerEvent.Create(caster.BoltEntity.Controller, ReliabilityModes.ReliableOrdered);

            spellCastAnswer.SpellId           = spellInfo.Id;
            spellCastAnswer.Result            = (int)SpellCastResult.Success;
            spellCastAnswer.ProcessingEntries = processingToken;
            spellCastAnswer.Send();
        }
        private void OnSpellLaunch(Unit caster, int spellId, SpellProcessingToken processingToken)
        {
            if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo))
            {
                return;
            }

            if (spellSounds.SoundInfos.TryGetValue(spellInfo, out SpellSoundInfo spellSoundSettings))
            {
                if (spellInfo.ExplicitTargetType == SpellExplicitTargetType.Destination)
                {
                    spellSoundSettings.PlayAtPoint(processingToken.Destination, SpellSoundEntry.UsageType.Destination);
                }
                else
                {
                    spellSoundSettings.PlayAtPoint(spellInfo.HasAttribute(SpellCustomAttributes.LaunchSourceIsExplicit)
                        ? processingToken.Source
                        : caster.Position, SpellSoundEntry.UsageType.Cast);
                }
            }
        }