public void Bind(GameObject owner)
    {
        if (owner == null)
        {
            _heldBy = HeldBy.None;
        }
        else
        {
            switch (owner.tag)
            {
            case "Enemy":
                _heldBy = HeldBy.Enemy;
                //this.transform.SetParent(owner.transform, true); // CB: No longer setting the parent, as it was ignoring physics collisions when dashing
                _transformToFollow      = owner.transform.Find("CarryLocation");
                this.transform.position = _transformToFollow.position;
                break;

            case "Player":
                _heldBy = HeldBy.Player;
                _gameInfo.SetGameState(GameInfo.GameState.Escape);
                //this.transform.SetParent(owner.transform, true); // CB: No longer setting the parent, as it was ignoring physics collisions when dashing
                _transformToFollow      = owner.transform.Find("CarryLocation");
                this.transform.position = _transformToFollow.position;
                break;

            default:
                Debug.Log("<color=blue>Memento Error: Memento told to bind to something other than Enemy or Player!</color>");
                _heldBy = HeldBy.None;
                break;
            }
        }
    }
 public void Release()
 {
     _heldBy = HeldBy.None;
     //this.transform.SetParent(null); // CB: No longer setting the parent, as it was ignoring physics collisions when dashing
     _transformToFollow = null;
     _maxHeight         = new Vector3(transform.position.x, _baseHeight + 0.25f, transform.position.z);
     _lowerHeight       = new Vector3(transform.position.x, _baseHeight - 0.25f, transform.position.z);
 }
Example #3
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile)
                {
                    ((Mobile)RootParent).PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                if (HeldBy != null)
                {
                    HeldBy.DropHolding();
                }

                if (RootParent is Mobile)
                {
                    Mobile parent = (Mobile)RootParent;
                    parent.SendLocalizedMessage(1060583);                               //The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    List <Mobile>     toDamage = new List <Mobile>();
                    IPooledEnumerable eable    = Map.GetMobilesInRange(Location, 1);

                    foreach (Mobile m in eable)
                    {
                        toDamage.Add(m);
                    }
                    eable.Free();

                    Mobile victim;
                    for (int i = 0; i < toDamage.Count; ++i)
                    {
                        victim = toDamage[i];

                        if (m_LitBy == null || (SpellHelper.ValidIndirectTarget(m_LitBy, victim) && m_LitBy.CanBeHarmful(victim, false)))
                        {
                            if (m_LitBy != null)
                            {
                                m_LitBy.DoHarmful(victim);
                            }

                            AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                        }
                    }
                    (new FirebombField(m_LitBy, toDamage)).MoveToWorld(Location, Map);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }
Example #4
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile)
                {
                    ((Mobile)RootParent).PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                if (HeldBy != null)
                {
                    HeldBy.DropHolding();
                }

                if (m_Users != null)
                {
                    foreach (Mobile m in m_Users)
                    {
                        ThrowTarget targ = m.Target as ThrowTarget;

                        if (targ != null && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile)
                {
                    Mobile parent = (Mobile)RootParent;
                    parent.SendLocalizedMessage(1060583);         // The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    IEnumerable <Mobile> targets = GetTargets();

                    foreach (Mobile victim in targets)
                    {
                        if (m_LitBy != null)
                        {
                            m_LitBy.DoHarmful(victim);
                        }

                        AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                    }

                    new FirebombField(m_LitBy, targets.ToList()).MoveToWorld(Location, Map);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }
Example #5
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile mobile)
                {
                    mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                HeldBy?.DropHolding();

                if (m_Users != null)
                {
                    foreach (Mobile m in m_Users)
                    {
                        if (m.Target is ThrowTarget targ && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile parent)
                {
                    parent.SendLocalizedMessage(1060583); // The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    IPooledEnumerable <Mobile> eable = Map.GetMobilesInRange(Location, 1);
                    List <Mobile> toDamage           = eable.ToList();

                    eable.Free();

                    for (int i = 0; i < toDamage.Count; ++i)
                    {
                        Mobile victim = toDamage[i];

                        if (m_LitBy == null || (SpellHelper.ValidIndirectTarget(m_LitBy, victim) &&
                                                m_LitBy.CanBeHarmful(victim, false)))
                        {
                            m_LitBy?.DoHarmful(victim);

                            AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                        }
                    }

                    new FirebombField(m_LitBy, toDamage).MoveToWorld(Location, Map);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }
Example #6
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                _timerToken.Cancel();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile mobile)
                {
                    mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                HeldBy?.DropHolding();

                if (m_Users != null)
                {
                    foreach (var m in m_Users)
                    {
                        if (m.Target is ThrowTarget targ && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile parent)
                {
                    parent.SendLocalizedMessage(1060583);         // The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    var eable = Map.GetMobilesInRange(Location, 1);
                    using var targets = PooledRefQueue <Mobile> .Create();

                    foreach (var m in eable)
                    {
                        if (m_LitBy == null || SpellHelper.ValidIndirectTarget(m_LitBy, m) &&
                            m_LitBy.CanBeHarmful(m, false))
                        {
                            targets.Enqueue(m);
                        }
                    }
                    eable.Free();

                    while (targets.Count > 0)
                    {
                        var victim = targets.Dequeue();
                        m_LitBy?.DoHarmful(victim);
                        AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                    }

                    var loc        = _thrownFromLocation;
                    var eastToWest = SpellHelper.GetEastToWest(loc, Location);
                    Effects.PlaySound(loc, Map, 0x20C);
                    var itemID = eastToWest ? 0x398C : 0x3996;

                    for (var i = -2; i <= 2; ++i)
                    {
                        var targetLoc = new Point3D(eastToWest ? loc.X + i : loc.X, eastToWest ? loc.Y : loc.Y + i, loc.Z);
                        new FireFieldSpell.FireFieldItem(itemID, targetLoc, m_LitBy, Map, TimeSpan.FromSeconds(9), i);
                    }
                }

                _timerToken.Cancel();
                Delete();
                break;
            }
            }
        }
Example #7
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile mobile)
                {
                    mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                if (HeldBy != null)
                {
                    HeldBy.DropHolding();
                }

                if (m_Users != null)
                {
                    for (var index = 0; index < m_Users.Count; index++)
                    {
                        Mobile m = m_Users[index];

                        if (m.Target is ThrowTarget targ && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile mobile)
                {
                    Mobile parent = mobile;
                    parent.SendLocalizedMessage(1060583);         // The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    IEnumerable <Mobile> targets = GetTargets();

                    var enumerable = new List <Mobile>();

                    foreach (var target in targets)
                    {
                        enumerable.Add(target);
                    }

                    for (var index = 0; index < enumerable.Count; index++)
                    {
                        Mobile victim = enumerable[index];

                        if (m_LitBy != null)
                        {
                            m_LitBy.DoHarmful(victim);
                        }

                        AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                    }

                    List <Mobile> list = new List <Mobile>();

                    for (var index = 0; index < enumerable.Count; index++)
                    {
                        var target = enumerable[index];

                        list.Add(target);
                    }

                    new FirebombField(m_LitBy, list).MoveToWorld(Location, Map);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }
Example #8
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile)
                {
                    ((Mobile)RootParent).PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                if (HeldBy != null)
                {
                    HeldBy.DropHolding();
                }

                if (m_Users != null)
                {
                    foreach (Mobile m in m_Users)
                    {
                        var targ = m.Target as ThrowTarget;

                        if (targ != null && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile)
                {
                    var parent = (Mobile)RootParent;
                    parent.SendLocalizedMessage(1060583);                                     // The firebomb explodes in your hand!
                    parent.Damage(Utility.Random(3) + 4);
                }
                else if (RootParent == null)
                {
                    Geometry.Circle2D(Location, Map, 4, FireBombEffect);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }