Example #1
0
            public static object HandleTrapTrigger(BaseTrap trap, User defender)
            {
                if (!Instance.Options.Pvp.RestrictPvp)
                {
                    return(null);
                }

                // A player can always trigger their own traps, to prevent exploiting this mechanic.
                if (defender.Player.userID == trap.OwnerID)
                {
                    return(null);
                }

                Area trapArea = Instance.Areas.GetByEntityPosition(trap);

                // If the defender is in a faction, they can trigger traps placed in areas claimed by factions with which they are at war.
                if (defender.Faction != null && trapArea.FactionId != null && Instance.Wars.AreFactionsAtWar(defender.Faction.Id, trapArea.FactionId))
                {
                    return(null);
                }

                // If the defender is in a PVP area or zone, the trap can trigger.
                // TODO: Ensure the trap is also in the PVP zone.
                if (IsUserInDanger(defender))
                {
                    return(null);
                }

                // Stop the trap from triggering.
                return(false);
            }
Example #2
0
    public void TrapBreaker(ManageDungeon dun, BaseCharacter target)
    {
        //サウンドを鳴らす
        SoundInformation.Sound.Play(SoundInformation.SoundType.AttackHit);

        //自オブジェクトとの距離を取得
        int dist = CurrentPoint.DistanceAbs(target.CurrentPoint);

        MapPoint vector     = CommonFunction.CharacterDirectionVector[target.Direction];
        MapPoint checkpoint = target.CurrentPoint;

        dun.SetUpTrapMap();
        //対象位置までのトラップをすべて破壊
        for (int i = 0; i <= dist; i++)
        {
            BaseTrap tr = dun.TrapMap.Get(checkpoint);
            if (CommonFunction.IsNull(tr) == false)
            {
                EffectSmoke.CreateObject(tr, false).Play();
                dun.RemoveTrap(tr);
                ManageDungeon.KillObjectNow(tr);

                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.TrapBreak, tr.DisplayNameInMessage,
                                  CommonFunction.StateNames[StateAbnormal.Slow]));
            }
            //1マス先を取得
            checkpoint = checkpoint.Add(vector);
        }
    }
Example #3
0
 public void SelectTrap(TRAP_ID pID)
 {
     for(int i = 0; i < trapList.Count; i++){
         if(trapList[i].trapID == pID){
             whichTrap = trapList[i];
         }
     }
 }
Example #4
0
 // Update is called once per frame
 public bool PlayerCanDisable(PlayerStats stats, BaseTrap trap)
 {
     if (stats.wood >= trap.woodDismantleCost &&
         stats.metal >= trap.metalDismantleCost &&
         stats.rope >= trap.ropeDismantleCost)
     {
         return(true);
     }
     return(false);
 }
Example #5
0
        //Traps and mines
        private object OnTrapTrigger(BaseTrap trap, GameObject go)
        {
            var basePlayer = go.GetComponent <BasePlayer>();

            if (basePlayer != null && _data.Contains(basePlayer))
            {
                return(false);
            }

            return(null);
        }
Example #6
0
        object OnTrapTrigger(BaseTrap trap, GameObject obj)
        {
            var player = obj.GetComponent <BasePlayer>();

            if (trap == null || player == null)
            {
                return(null);
            }

            User defender = Users.Get(player);

            return(Pvp.HandleTrapTrigger(trap, defender));
        }
Example #7
0
 public bool AICanDisable(BaseAI ai, BaseTrap trap)
 {
     if (ai.wood >= trap.woodDismantleCost &&
         ai.metal >= trap.metalDismantleCost &&
         ai.rope >= trap.metalDismantleCost)
     {
         if (ai.tag == trap.EnemyTag)
         {
             return(true);
         }
     }
     return(false);
 }
Example #8
0
 bool CheckResources(BaseTrap trap)
 {
     if (stat.wood >= trap.woodCost)
     {
         if (stat.rope >= trap.ropeCost)
         {
             if (stat.metal >= trap.metalCost)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #9
0
    public static BaseTrap GetTrap(int floor)
    {
        BaseTrap trap = new BaseTrap();

        trap.Initialize();
        if (CommonFunction.IsRandom(0.7f) == true)
        {
            trap = TableTrap.GetTrap(30007);
        }
        else
        {
            trap = TableTrap.GetTrap(30006);
        }
        return(trap);
    }
Example #10
0
 object OnTrapTrigger(BaseTrap trap, GameObject obj)
 {
     if (trap is Landmine)
     {
         BasePlayer target = obj.GetComponent <BasePlayer>();
         if (target)
         {
             if (target.userID == trap.OwnerID)
             {
                 return(false);
             }
             else if (Convert.ToBoolean(Friends?.CallHook("AreFriends", target.userID, trap.OwnerID)))
             {
                 return(false);
             }
         }
     }
     return(null);
 }
Example #11
0
    public BaseTrap[] TurnAction(ManageDungeon dun)
    {
        //効果発動
        switch (TType)
        {
        case TrapType.Ember:

            int wf = 0;
            if (CommonFunction.IsNull(Options) == false)
            {
                foreach (BaseOption o in Options)
                {
                    if (o.OType == OptionType.Wildfire)
                    {
                        wf = o.Plus;
                        o.Plus--;
                    }
                }
            }

            //燃え広がる
            if (wf > 0)
            {
                //周囲からトラップのない位置を取得
                MapPoint point = dun.GetEmptyTrapPoint(CurrentPoint);
                //場所が取得できたら燃え広がる
                if (CommonFunction.IsNull(point) == false)
                {
                    BaseTrap trap = TableTrap.GetTrap(CommonConst.ObjNo.Ember);
                    trap.IsVisible = true;
                    trap.SetThisDisplayTrap(CurrentPoint.X, CurrentPoint.Y);
                    trap.Options = CommonFunction.CloneOptions(this.Options);

                    return(new BaseTrap[] { trap });
                }
            }
            break;
        }

        return(null);
    }
Example #12
0
 //check for traps within player sight
 protected BaseTrap CheckForTraps(Collider[] collidersInRange, Plane[] planes)
 {
     //check each collider in range of player
     for (int i = 0; i < collidersInRange.Length; i++)
     {
         //check if collider is within AI's camera's view frustum
         if (GeometryUtility.TestPlanesAABB(planes, collidersInRange[i].bounds))
         {
             //check for anything in between AI and trap
             RaycastHit hit;
             if (Physics.Raycast(cam.transform.position,
                                 collidersInRange[i].transform.position - cam.transform.position, out hit, 100, sightLayer))
             {
                 if (hit.collider.gameObject.layer == 10)
                 {
                     BaseTrap trap = collidersInRange[i].GetComponent <BaseTrap>();
                     return(trap);
                 }
             }
         }
     }
     return(null);
 }
Example #13
0
    public static BaseTrap GetTrap(long objNo)
    {
        TableTrapData data = Array.Find(Table, i => i.ObjNo == objNo);
        BaseTrap      item = new BaseTrap();

        item.Initialize();
        item.ObjNo = data.ObjNo;
        if (GameStateInformation.IsEnglish == false)
        {
            item.DisplayName = data.DisplayName;
        }
        else
        {
            item.DisplayName = data.DisplayNameEn;
        }
        item.InstanceName    = data.InstanceName;
        item.TType           = data.Ttype;
        item.CountStart      = data.CountStart;
        item.ProbStart       = data.ProbStart;
        item.ProbReduce      = data.ProbReduce;
        item.CommonNumber    = data.CommonNumber;
        item.PerPlayerDamage = data.PerPlayerDamage;
        return(item);
    }
Example #14
0
        private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
        {
            if (!ignoreProjectiles)
            {
                return(null);
            }
            BaseTrap trap = entity.GetComponent <BaseTrap>();

            if (!trap)
            {
                return(null);
            }
            if (!info.IsProjectile())
            {
                return(null);
            }
            BearTrap bearTrap = entity.GetComponent <BearTrap>();

            if (bearTrap)
            {
                bearTrap.Arm();
            }
            return(true);
        }
Example #15
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         RaycastHit normalHit;
         if (Physics.Raycast(ray, out hit, 10f))
         {
             if (hit.collider)
             {
                 Ray normalCheck = new Ray(hit.point, hit.normal);
                 Debug.DrawRay(hit.point, hit.normal, Color.blue);
                 if (Physics.Raycast(normalCheck, out normalHit, 15f))
                 {
                     if (normalHit.collider)
                     {
                         if (CheckResources(wireTrap))
                         {
                             wireTrap.SetTrap(hit, normalHit, "Enemy");
                             stat.RemoveResources(wireTrap.woodCost, wireTrap.ropeCost, wireTrap.metalCost);
                         }
                     }
                 }
             }
         }
     }
     else if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, 10f))
         {
             if (hit.collider)
             {
                 if (CheckResources(pit))
                 {
                     pit.SetTrap(hit, "Enemy");
                     stat.RemoveResources(pit.woodCost, pit.ropeCost, pit.metalCost);
                 }
             }
         }
     }
     else if (Input.GetButtonDown("Interact"))
     {
         RaycastHit hit;
         if (Physics.SphereCast(cam.transform.position, 1f, cam.transform.forward, out hit, 5f, 1 << 10))
         {
             if (hit.collider.gameObject.tag == "Trap")
             {
                 BaseTrap trap = hit.collider.gameObject.GetComponent <BaseTrap>();
                 if (trap.EnemyTag == this.gameObject.tag)
                 {
                     if (dismantle.PlayerCanDisable(stat, trap))
                     {
                         dismantle.DisableTrap(trap.gameObject);
                         stat.RemoveResources(trap.woodDismantleCost, trap.ropeDismantleCost, trap.metalDismantleCost);
                     }
                 }
             }
         }
     }
 }
Example #16
0
 private void OnTrapTrigger(BaseTrap trap)
 {
     HookCalled("OnTrapTrigger");
 }
Example #17
0
 protected virtual void Update()
 {
     if (agent.isActiveAndEnabled)
     {
         Collider[] collidersInRange;
         cam.enabled = true;
         Plane[] planes = GeometryUtility.CalculateFrustumPlanes(cam);
         cam.enabled = false;
         //removed due to no combat
         // BaseAI enemyFound = CheckForEnemies(collidersInRange, planes);
         if (!agent.hasPath)
         {
             if (flagManager.isCarrying)
             {
                 agent.destination = myFlag.transform.position;
             }
             else
             {
                 agent.destination = enemyFlag.transform.position;
             }
         }
         // if (enemyFound) removed for no combat
         if (false)
         {
             //insert combat if needed
         }
         else
         {
             collidersInRange = Physics.OverlapSphere(transform.position, 100f, 1 << 10);
             BaseTrap trapFound = CheckForTraps(collidersInRange, planes);
             if (trapFound)
             {
                 int chanceToSee = Random.Range(0, 101);
                 if (chanceToSee <= 50)
                 {
                     trapFound.wasSeen = true;
                     trapFound.Invoke("ResetSeen", 5f);
                     canDisable = false;
                 }
                 else
                 {
                     trapFound.wasSeen = true;
                     if (dismantler.AICanDisable(this, trapFound))
                     {
                         agent.destination = trapFound.transform.position;
                         canDisable        = true;
                     }
                     else
                     {
                         trapFound.obstacle.enabled = true;
                         canDisable = false;
                     }
                     trapFound.Invoke("ResetSeen", 5f);
                 }
             }
             else
             {
                 collidersInRange = Physics.OverlapSphere(transform.position, 100f, 1 << 8);
                 GameObject resourceFound = CheckForResources(collidersInRange, planes);
                 if (resourceFound)
                 {
                     //move to resourceFound and collect
                     agent.destination = resourceFound.transform.position;
                     resourceFound     = null;
                 }
                 else
                 {
                     if (!flagManager.isCarrying)
                     {
                         agent.destination = enemyFlag.transform.position;
                     }
                     collidersInRange = Physics.OverlapSphere(transform.position, 100f, 1 << 11);
                     RaycastHit hit;
                     GameObject trapPlaceFound = CheckForSpot(collidersInRange, planes, out hit);
                     if (trapPlaceFound)
                     {
                         if (trapPlaceFound.tag == "pitPosition")
                         {
                             traps[0].SetTrap(hit, enemyTag);
                         }
                         else
                         {
                             RaycastHit normal;
                             Physics.Raycast(hit.point, hit.normal, out normal, 15f);
                             traps[1].SetTrap(hit, normal, enemyTag);
                         }
                         Destroy(trapPlaceFound);
                     }
                 }
             }
         }
     }
 }
Example #18
0
 private void OnTrapSnapped(BaseTrap trap, GameObject go)
 {
     HookCalled("OnTrapSnapped");
 }
Example #19
0
        public void Target(IPoint3D p)
        {
            if (!Caster.CanSee(p))
            {
                Caster.SendLocalizedMessage(500237);                   // Target can not be seen.
            }
            else if (CheckSequence())
            {
                /// WIZARD WANTS THIS TO WORK FOR NORMAL TRAPS, HIDDEN TRAPS, & HIDDEN CONTAINERS ///
                IPooledEnumerable TitemsInRange = Caster.Map.GetItemsInRange(new Point3D(p), 1 + (int)(Caster.Skills[SkillName.Magery].Value / 20.0));
                string            sTrap;
                foreach (Item item in TitemsInRange)
                {
                    if (item is BaseTrap)
                    {
                        BaseTrap trap = (BaseTrap)item;

                        if (trap is FireColumnTrap)
                        {
                            sTrap = "(fire column trap)";
                        }
                        else if (trap is FlameSpurtTrap)
                        {
                            sTrap = "(fire spurt trap)";
                        }
                        else if (trap is GasTrap)
                        {
                            sTrap = "(poison gas trap)";
                        }
                        else if (trap is GiantSpikeTrap)
                        {
                            sTrap = "(giant spike trap)";
                        }
                        else if (trap is MushroomTrap)
                        {
                            sTrap = "(mushroom trap)";
                        }
                        else if (trap is SawTrap)
                        {
                            sTrap = "(saw blade trap)";
                        }
                        else if (trap is SpikeTrap)
                        {
                            sTrap = "(spike trap)";
                        }
                        else if (trap is StoneFaceTrap)
                        {
                            sTrap = "(stone face trap)";
                        }
                        else
                        {
                            sTrap = "";
                        }

                        Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, Server.Items.CharacterDatabase.GetMySpellHue(Caster, 0), 0, 5024, 0);
                        Effects.PlaySound(item.Location, item.Map, 0x1FA);
                        Caster.SendMessage("There is a trap nearby! " + sTrap + "");
                    }
                    else if (item is HiddenTrap)
                    {
                        Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, Server.Items.CharacterDatabase.GetMySpellHue(Caster, 0), 0, 5024, 0);
                        Effects.PlaySound(item.Location, item.Map, 0x1FA);
                        Caster.SendMessage("There is a hidden floor trap somewhere nearby!");
                    }
                    else if (item is HiddenChest)
                    {
                        Caster.SendMessage("Your eye catches something nearby.");
                        string where = Server.Misc.Worlds.GetRegionName(Caster.Map, Caster.Location);

                        int money = Utility.RandomMinMax(50, 100);

                        int level = (int)(Caster.Skills[SkillName.Magery].Value / 16);
                        if (level < 1)
                        {
                            level = 1;
                        }
                        if (level > 6)
                        {
                            level = 6;
                        }

                        switch (Utility.RandomMinMax(1, level))
                        {
                        case 1: level = 1; break;

                        case 2: level = 2; break;

                        case 3: level = 3; break;

                        case 4: level = 4; break;

                        case 5: level = 5; break;

                        case 6: level = 6; break;
                        }

                        if (Utility.RandomMinMax(1, 3) > 1)
                        {
                            // DO NOTHING BECAUSE THE DETECT HIDDEN SKILL IS MUCH BETTER
                        }
                        else if (level > 4)
                        {
                            if (level == 5)
                            {
                                level = 1;
                            }
                            else
                            {
                                level = 2;
                            }

                            HiddenBox mBox = new HiddenBox(level, where, Caster);

                            Point3D loc = item.Location;
                            mBox.MoveToWorld(loc, Caster.Map);
                            Effects.SendLocationParticles(EffectItem.Create(mBox.Location, mBox.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, Server.Items.CharacterDatabase.GetMySpellHue(Caster, 0), 0, 5024, 0);
                            Effects.PlaySound(mBox.Location, mBox.Map, 0x1FA);
                        }
                        else
                        {
                            Gold coins = new Gold((money * level));

                            Point3D loc = item.Location;
                            coins.MoveToWorld(loc, Caster.Map);
                            Effects.SendLocationParticles(EffectItem.Create(coins.Location, coins.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, Server.Items.CharacterDatabase.GetMySpellHue(Caster, 0), 0, 5024, 0);
                            Effects.PlaySound(coins.Location, coins.Map, 0x1FA);
                        }

                        item.Delete();
                    }
                }
                TitemsInRange.Free();                 /////////////////////////////////////////////////////////////////////////////

                SpellHelper.Turn(Caster, p);

                SpellHelper.GetSurfaceTop(ref p);

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

                Map map = Caster.Map;

                if (map != null)
                {
                    IPooledEnumerable eable = map.GetMobilesInRange(new Point3D(p), 1 + (int)(Caster.Skills[SkillName.Magery].Value / 20.0));

                    foreach (Mobile m in eable)
                    {
                        if (m.Hidden && (m.AccessLevel == AccessLevel.Player || Caster.AccessLevel > m.AccessLevel) && CheckDifficulty(Caster, m))
                        {
                            targets.Add(m);
                        }
                    }

                    eable.Free();
                }

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

                    m.RevealingAction();

                    m.FixedParticles(0x375A, 9, 20, 5049, Server.Items.CharacterDatabase.GetMySpellHue(Caster, 0), 0, EffectLayer.Head);
                    m.PlaySound(0x1FD);
                }
            }

            FinishSequence();
        }
Example #20
0
    /// <summary>
    /// 投げる効果(誰かに当たった時)
    /// </summary>
    private bool ThrowActionEffect(ManageDungeon dun, PlayerCharacter player, BaseCharacter target)
    {
        switch (BType)
        {
        case BallType.Fire:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Bomb);

            int damage = FireBallFixDamage + Mathf.FloorToInt(player.BaseAttack * 2);

            AttackState atState = target.AddDamage(damage);
            //ボールエフェクト
            EffectFireBallLanding.CreateObject(target).Play();

            //ダメージエフェクト
            EffectDamage d = EffectDamage.CreateObject(target);
            d.SetText(damage.ToString(), AttackState.Hit);
            d.Play();

            //ヒットメッセージ
            DisplayInformation.Info.AddMessage(
                target.GetMessageAttackHit(damage));

            //対象が死亡したら
            if (atState == AttackState.Death)
            {
                if (target.Type == ObjectType.Player)
                {
                    ScoreInformation.Info.CauseDeath =
                        string.Format(CommonConst.DeathMessage.Item, this.DisplayNameNormal);

                    ScoreInformation.Info.CauseDeathType = DeathCouseType.Item;
                }

                DisplayInformation.Info.AddMessage(
                    target.GetMessageDeath(target.HaveExperience));

                player.Death(target, player.AttackInfo);
                target.DeathAction(dun);
            }
            break;

        case BallType.Gyro:

            SoundInformation.Sound.Play(SoundInformation.SoundType.BucketFall);

            //ターゲットが吹き飛ぶ先のポイントを取得
            bool     isWall;
            MapPoint point = dun.GetBlow(target.CurrentPoint, Direction, out isWall);

            //対象のポイントが取得できなければ
            if (CommonFunction.IsNull(point) == true)
            {
            }
            //対象ポイントが取得できればそこに移動
            else
            {
                if (typeof(BaseEnemyCharacter) == target.GetType())
                {
                    ((BaseEnemyCharacter)target).MoveState = EnemySearchState.FightPlayer;
                }
                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.BlowCharacter, target.DisplayNameInMessage));
                target.BlowDirection = Direction;
                target.BlowPoint     = point;
                target.MoveSpeed     = CommonConst.SystemValue.MoveSpeedDash;
                dun.MoveCharacter(point, target);

                //対象に衝突ダメージ
                if (isWall == true)
                {
                    target.BlowAfterDamage = GyroFixDamage;
                }

                //吹っ飛び先に誰かがいた場合
                MapPoint      vector = CommonFunction.CharacterDirectionVector[Direction];
                MapPoint      next   = MapPoint.Get(point.X + vector.X, point.Y + vector.Y);
                BaseCharacter second = dun.CharacterMap.Get(point.X, point.Y);
                if (CommonFunction.IsNull(second) == false)
                {
                    second.BlowAfterDamage = GyroFixDamage;
                    second.BlowPoint       = second.CurrentPoint;
                }
            }

            break;

        case BallType.Change:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            if (typeof(BaseEnemyCharacter) == target.GetType())
            {
                ((BaseEnemyCharacter)target).MoveState = EnemySearchState.FightPlayer;
            }
            //ターゲットとプレイヤーの場所を交換

            EffectSmoke.CreateObject(target).Play();
            EffectSmoke.CreateObject(player).Play();
            MapPoint tarp = target.CurrentPoint;
            target.SetPosition(player.CurrentPoint.X, player.CurrentPoint.Y);
            player.SetPosition(tarp.X, tarp.Y);
            DisplayInformation.Info.AddMessage(
                string.Format(CommonConst.Message.ChangePoint, target.DisplayNameInMessage));
            break;

        case BallType.Pickoff:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //対象に混乱を付与
            int result = target.AddStateAbnormal((int)StateAbnormal.Confusion);
            //対象が混乱になったらメッセージを表示
            if (result != 0)
            {
                EffectSmoke.CreateObject(target).Play();
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Confusion, target));
            }
            break;

        case BallType.Bean:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //対象に麻痺を付与
            int bresult = target.AddStateAbnormal((int)StateAbnormal.Palalysis);
            //対象が麻痺になったらメッセージを表示
            if (bresult != 0)
            {
                EffectSmoke.CreateObject(target).Play();
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Palalysis, target));
            }
            break;

        case BallType.Decoy:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //対象にデコイを付与
            int dresult = target.AddStateAbnormal((int)StateAbnormal.Decoy);
            //対象がデコイになったらメッセージを表示
            if (dresult != 0)
            {
                EffectSmoke.CreateObject(target).Play();
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Decoy, target));
            }
            break;

        case BallType.Slow:

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.Smoke);

            //対象にスローを付与
            int sresult = target.AddStateAbnormal((int)StateAbnormal.Slow);
            //対象がスローになったらメッセージを表示
            if (sresult != 0)
            {
                EffectSmoke.CreateObject(target).Play();
                DisplayInformation.Info.AddMessage(
                    CommonFunction.GetAbnormalMessage(StateAbnormal.Slow, target));
            }
            break;

        //ナックル
        case BallType.Knuckle:

            List <BallType> blist = new List <BallType>();
            foreach (BallType val in Enum.GetValues(typeof(BallType)))
            {
                blist.Add(val);
            }
            blist.Remove(BallType.Knuckle);
            blist.Remove(BallType.Handmaid);

            //ナックル以外の効果をランダムで取得
            BallType temp = blist[UnityEngine.Random.Range(0, blist.Count)];

            BallBase b = new BallBase();
            b.CurrentPoint = CurrentPoint;
            b.Direction    = Direction;
            b.BType        = temp;
            //効果を発動
            b.ThrowActionEffect(dun, player, target);
            break;

        case BallType.Trap:

            TrapBreaker(dun, player);
            break;

        case BallType.Handmaid:

            //ヒットエフェクト
            EffectFireBallLanding.CreateObject(target).Play();

            //サウンドを鳴らす
            SoundInformation.Sound.Play(SoundInformation.SoundType.AttackHit);

            //範囲拡大がついているとき
            int   plus;
            float cf;
            int   dist = 0;
            if (CommonFunction.HasOptionType(this.Options, OptionType.Wildfire, out plus, out cf) == true)
            {
                dist = plus;
            }

            dun.SetUpCharacterMap();
            List <BaseCharacter> targets = dun.GetNearCharacters(target.CurrentPoint, dist, true);

            foreach (BaseCharacter t in targets)
            {
                //int damage2 = FireBallFixDamage + Mathf.FloorToInt(player.BaseAttack * 2);
                int damage2 = Mathf.FloorToInt((15 + player.BaseAttack) / (target.CurrentPoint.DistanceAbs(t.CurrentPoint) + 1));

                //効果増幅があったら
                if (CommonFunction.HasOptionType(this.Options, OptionType.EffectUp, out plus, out cf) == true)
                {
                    damage2 = damage2 + plus * (int)cf;
                }
                //効果縮小があったら
                if (CommonFunction.HasOptionType(this.Options, OptionType.EffectDown, out plus, out cf) == true)
                {
                    damage2 = damage2 - plus * (int)cf;
                }

                //ダメージ増減30%
                float rand = 0.3f;
                if (CommonFunction.HasOptionType(this.Options, OptionType.EffectStabile, out plus, out cf) == true)
                {
                    rand -= cf * plus;
                }
                else if (CommonFunction.HasOptionType(this.Options, OptionType.EffectNotStabile, out plus, out cf) == true)
                {
                    rand += cf * plus;
                }

                damage2 += Mathf.CeilToInt(UnityEngine.Random.Range(-rand * damage2, rand * damage2));

                //通常ダメージの場合
                if (CommonFunction.HasOptionType(this.Options, OptionType.ReverceDamage) == false)
                {
                    AttackState atState2 = t.AddDamage(damage2);

                    //ダメージエフェクト
                    EffectDamage d2 = EffectDamage.CreateObject(t);
                    d2.SetText(damage2.ToString(), AttackState.Hit);
                    d2.Play();

                    //ヒットメッセージ
                    DisplayInformation.Info.AddMessage(
                        t.GetMessageAttackHit(damage2));

                    //対象が死亡したら
                    if (atState2 == AttackState.Death)
                    {
                        DisplayInformation.Info.AddMessage(
                            t.GetMessageDeath(t.HaveExperience));

                        if (t.Type == ObjectType.Player)
                        {
                            ScoreInformation.Info.CauseDeath =
                                string.Format(CommonConst.DeathMessage.Item, this.DisplayNameNormal);

                            ScoreInformation.Info.CauseDeathType = DeathCouseType.Item;

                            t.Death();
                        }
                        else
                        {
                            if (IsExp == true)
                            {
                                player.Death(t, player.AttackInfo);
                            }
                            else
                            {
                                t.Death();
                            }
                        }
                        t.DeathAction(dun);
                    }
                }
                //基本効果反転
                else
                {
                    t.RecoverHp(damage2);

                    //ヒットエフェクト
                    EffetHitShockWave.CreateObject(t).Play();

                    //ダメージエフェクト
                    EffectDamage d2 = EffectDamage.CreateObject(t);
                    d2.SetText(damage2.ToString(), AttackState.Heal);
                    d2.Play();

                    //ヒットメッセージ
                    DisplayInformation.Info.AddMessage(
                        string.Format(CommonConst.Message.RecoverHp, t.DisplayNameInMessage));
                }
            }

            //状態異常の付与
            EffectAbnormal(targets);

            //火柱があれば火柱を立てる
            if (CommonFunction.HasOptionType(this.Options, OptionType.CatchingFire) == true)
            {
                dun.SetUpTrapMap();
                if (CommonFunction.IsNull(dun.TrapMap.Get(CurrentPoint)) == true)
                {
                    BaseTrap trap = TableTrap.GetTrap(CommonConst.ObjNo.Ember);
                    trap.Options   = CommonFunction.CloneOptions(this.Options);
                    trap.IsVisible = true;
                    trap.SetThisDisplayTrap(CurrentPoint.X, CurrentPoint.Y);
                    dun.AddNewTrap(trap);

                    DisplayInformation.Info.AddMessage(
                        CommonConst.Message.TrapEmber);
                }
            }

            break;

        case BallType.Fumble:
            //対象のレベルが2以上ならレベルを下げる
            if (target.Level > 1)
            {
                if (target.Type == ObjectType.Enemy)
                {
                    BaseEnemyCharacter enemy = ((BaseEnemyCharacter)target);
                    enemy.Level--;
                    TableEnemy.SetLevel(enemy, enemy.Level,
                                        DisplayInformation.Info.Floor,
                                        DungeonInformation.Info.EnemyHpProb,
                                        DungeonInformation.Info.EnemyAtkProb,
                                        DungeonInformation.Info.EnemyExpProb,
                                        DungeonInformation.Info.StartProbHp,
                                        DungeonInformation.Info.StartProbAtk,
                                        DungeonInformation.Info.StartProbExp);

                    DisplayInformation.Info.AddMessage(
                        string.Format(CommonConst.Message.LevelDownPlayer, enemy.DisplayNameInMessage));

                    EffectBadSmoke.CreateObject(enemy).Play();
                }
            }

            break;

        case BallType.Winning:

            if (target.Type == ObjectType.Enemy)
            {
                BaseEnemyCharacter enemy = ((BaseEnemyCharacter)target);
                enemy.Level++;
                TableEnemy.SetLevel(enemy, enemy.Level,
                                    DisplayInformation.Info.Floor,
                                    DungeonInformation.Info.EnemyHpProb,
                                    DungeonInformation.Info.EnemyAtkProb,
                                    DungeonInformation.Info.EnemyExpProb,
                                    DungeonInformation.Info.StartProbHp,
                                    DungeonInformation.Info.StartProbAtk,
                                    DungeonInformation.Info.StartProbExp);

                DisplayInformation.Info.AddMessage(
                    string.Format(CommonConst.Message.LevelUpPlayer, enemy.DisplayNameInMessage));

                EffectFlareCore.CreateObject(enemy).Play();
            }
            break;

        case BallType.Four:

            if (target.Type == ObjectType.Enemy)
            {
                BaseEnemyCharacter enemy = ((BaseEnemyCharacter)target);

                if (enemy.IsFourBallCount() == true)
                {
                    int dam = Mathf.CeilToInt(enemy.MaxHp);

                    AttackState atstate = target.AddDamage(dam);
                    //ボールエフェクト
                    EffetHitShockWave.CreateObject(enemy).Play();

                    //ダメージエフェクト
                    EffectDamage dt = EffectDamage.CreateObject(target);
                    dt.SetText(dam.ToString(), AttackState.Hit);
                    dt.Play();

                    //ヒットメッセージ
                    DisplayInformation.Info.AddMessage(
                        target.GetMessageAttackHit(dam));

                    SoundInformation.Sound.Play(SoundInformation.SoundType.AttackHit);

                    //対象が死亡したら
                    if (atstate == AttackState.Death)
                    {
                        if (target.Type == ObjectType.Player)
                        {
                            ScoreInformation.Info.CauseDeath =
                                string.Format(CommonConst.DeathMessage.Item, this.DisplayNameNormal);

                            ScoreInformation.Info.CauseDeathType = DeathCouseType.Item;
                        }
                        DisplayInformation.Info.AddMessage(
                            target.GetMessageDeath(target.HaveExperience));

                        player.Death(target, player.AttackInfo);
                        target.DeathAction(dun);
                    }
                }
                else
                {
                    SoundInformation.Sound.Play(SoundInformation.SoundType.AttackHit);
                    //ボールエフェクト
                    EffetHitShockWave.CreateObject(enemy).Play();
                }
            }

            break;

        case BallType.Emery:

            if (target.Type == ObjectType.Enemy)
            {
                BaseEnemyCharacter enemy = ((BaseEnemyCharacter)target);

                if (enemy.IsBoss() == false)
                {
                    GameStateInformation.Info.EmeryTarget = target.ObjNo;

                    DisplayInformation.Info.AddMessage(
                        string.Format(CommonConst.Message.EmeryCharacter, target.DisplayNameInMessage));

                    List <BaseCharacter> emeryies = dun.Characters.FindAll(i => i.ObjNo == target.ObjNo);

                    SoundInformation.Sound.Play(SoundInformation.SoundType.Summon);

                    foreach (BaseCharacter c in emeryies)
                    {
                        EffectSmoke.CreateObject(c, false).Play();

                        dun.RemoveCharacter(c);
                        ManageDungeon.KillObjectNow(c);
                    }
                }
            }
            break;
        }
        Options = null;

        return(true);
    }
Example #21
0
        public static bool DetectSomething(Item item, Mobile m, bool skillCheck)
        {
            bool   foundAnyone = false;
            string sTrap;

            bool foundIt = false;

            if (m.CheckSkill(SkillName.DetectHidden, 0, 125))
            {
                foundIt = true;
            }
            else if ((AosAttributes.GetValue(m, AosAttribute.NightSight) > 0 || m.LightLevel > 0) && 1 == Utility.RandomMinMax(1, 20))
            {
                foundIt = true;
            }

            if (m is PlayerMobile && m.Alive && (!skillCheck || foundIt))
            {
                if (item is BaseTrap)
                {
                    BaseTrap trap = (BaseTrap)item;

                    if (trap is FireColumnTrap)
                    {
                        sTrap = "(fire column trap)";
                    }
                    else if (trap is FlameSpurtTrap)
                    {
                        sTrap = "(fire spurt trap)";
                    }
                    else if (trap is GasTrap)
                    {
                        sTrap = "(poison gas trap)";
                    }
                    else if (trap is GiantSpikeTrap)
                    {
                        sTrap = "(giant spike trap)";
                    }
                    else if (trap is MushroomTrap)
                    {
                        sTrap = "(odd mushroom)";
                    }
                    else if (trap is SawTrap)
                    {
                        sTrap = "(saw blade trap)";
                    }
                    else if (trap is SpikeTrap)
                    {
                        sTrap = "(spike trap)";
                    }
                    else if (trap is StoneFaceTrap)
                    {
                        sTrap = "(stone face trap)";
                    }
                    else
                    {
                        sTrap = "";
                    }

                    Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5024);
                    Effects.PlaySound(item.Location, item.Map, 0x1FA);
                    m.SendMessage("There is a trap nearby! " + sTrap + "");
                    foundAnyone = true;
                }
                else if (item is BaseDoor && (item.ItemID == 0x35E ||
                                              item.ItemID == 0xF0 ||
                                              item.ItemID == 0xF2 ||
                                              item.ItemID == 0x326 ||
                                              item.ItemID == 0x324 ||
                                              item.ItemID == 0x32E ||
                                              item.ItemID == 0x32C ||
                                              item.ItemID == 0x314 ||
                                              item.ItemID == 0x316 ||
                                              item.ItemID == 0x31C ||
                                              item.ItemID == 0x31E ||
                                              item.ItemID == 0xE8 ||
                                              item.ItemID == 0xEA ||
                                              item.ItemID == 0x34C ||
                                              item.ItemID == 0x356 ||
                                              item.ItemID == 0x35C ||
                                              item.ItemID == 0x354 ||
                                              item.ItemID == 0x344 ||
                                              item.ItemID == 0x346 ||
                                              item.ItemID == 0x34E ||
                                              item.ItemID == 0x334 ||
                                              item.ItemID == 0x336 ||
                                              item.ItemID == 0x33C ||
                                              item.ItemID == 0x33E))
                {
                    Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5024);
                    Effects.PlaySound(item.Location, item.Map, 0x1FA);
                    m.SendMessage("There is a hidden door nearby!");
                    foundAnyone = true;
                }
                else if (item is HiddenTrap)
                {
                    string textSay = "There is a hidden floor trap somewhere nearby!";
                    if (Server.Misc.Worlds.IsOnSpaceship(item.Location, item.Map))
                    {
                        textSay = "There is a dangerous area nearby!";
                    }
                    Effects.SendLocationParticles(EffectItem.Create(item.Location, item.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5024);
                    Effects.PlaySound(item.Location, item.Map, 0x1FA);
                    m.SendMessage(textSay);
                    foundAnyone = true;
                }
                else if (item is HiddenChest)
                {
                    m.SendMessage("Your eye catches something nearby.");
                    Map map = m.Map;
                    string where = Server.Misc.Worlds.GetRegionName(m.Map, m.Location);

                    int money = Utility.RandomMinMax(100, 200);

                    int level = (int)(m.Skills[SkillName.DetectHidden].Value / 10);
                    if (level < 1)
                    {
                        level = 1;
                    }
                    if (level > 10)
                    {
                        level = 10;
                    }

                    switch (Utility.RandomMinMax(1, level))
                    {
                    case 1: level = 1; break;

                    case 2: level = 2; break;

                    case 3: level = 3; break;

                    case 4: level = 4; break;

                    case 5: level = 5; break;

                    case 6: level = 6; break;

                    case 7: level = 7; break;

                    case 8: level = 8; break;

                    case 9: level = 9; break;

                    case 10: level = 10; break;
                    }

                    if (Utility.RandomMinMax(1, 3) > 1)
                    {
                        Item coins = new Gold((money * level));

                        if (Server.Misc.Worlds.IsOnSpaceship(item.Location, item.Map))
                        {
                            coins.Delete(); coins = new DDXormite(); coins.Amount = (int)((money * level) / 3);
                        }
                        else if (Server.Misc.Worlds.GetMyWorld(item.Map, item.Location, item.X, item.Y) == "the Underworld")
                        {
                            coins.Delete(); coins = new DDJewels(); coins.Amount = (int)((money * level) / 2);
                        }
                        else if (Utility.RandomMinMax(1, 100) > 99)
                        {
                            coins.Delete(); coins = new DDGemstones(); coins.Amount = (int)((money * level) / 2);
                        }
                        else if (Utility.RandomMinMax(1, 100) > 95)
                        {
                            coins.Delete(); coins = new DDGoldNuggets(); coins.Amount = (int)((money * level));
                        }
                        else if (Utility.RandomMinMax(1, 100) > 80)
                        {
                            coins.Delete(); coins = new DDSilver(); coins.Amount = (int)((money * level) * 5);
                        }
                        else if (Utility.RandomMinMax(1, 100) > 60)
                        {
                            coins.Delete(); coins = new DDCopper(); coins.Amount = (int)((money * level) * 10);
                        }

                        Point3D loc = item.Location;
                        coins.MoveToWorld(loc, map);
                        Effects.SendLocationParticles(EffectItem.Create(coins.Location, coins.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5024);
                        Effects.PlaySound(coins.Location, coins.Map, 0x1FA);
                    }
                    else
                    {
                        HiddenBox mBox = new HiddenBox(level, where, m);

                        Point3D loc = item.Location;
                        mBox.MoveToWorld(loc, map);
                        Effects.SendLocationParticles(EffectItem.Create(mBox.Location, mBox.Map, EffectItem.DefaultDuration), 0x376A, 9, 32, 5024);
                        Effects.PlaySound(mBox.Location, mBox.Map, 0x1FA);
                    }

                    foundAnyone = true;
                    item.Delete();
                }
            }
            return(foundAnyone);
        }
Example #22
0
 private void OnTrapArm(BaseTrap trap)
 {
     HookCalled("OnTrapArm");
 }
Example #23
0
 private void OnTrapTrigger(BaseTrap trap, UnityEngine.GameObject go)
 {
     HookCalled("OnTrapTrigger");
 }
Example #24
0
        public virtual void SpawnTrap()
        {
            Map map = this.Map;

            if (map == null)
            {
                return;
            }

            BaseTrap trap = null;

            int random = Utility.Random(100);

            if (22 > random)
            {
                trap = new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor);
            }
            else if (44 > random)
            {
                trap = new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor);
            }
            else if (66 > random)
            {
                trap = new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall);
            }
            else if (88 > random)
            {
                trap = new FireColumnTrap();
            }
            else
            {
                trap = new MushroomTrap();
            }

            if (trap == null)
            {
                return;
            }

            if (trap is FireColumnTrap || trap is MushroomTrap)
            {
                trap.Hue = 0x451;
            }

            // try 10 times to find a valid location
            for (int i = 0; i < 10; ++i)
            {
                int x = Utility.Random(this.m_RegionBounds.X, this.m_RegionBounds.Width);
                int y = Utility.Random(this.m_RegionBounds.Y, this.m_RegionBounds.Height);
                int z = this.Z;

                if (!map.CanFit(x, y, z, 16, false, false))
                {
                    z = map.GetAverageZ(x, y);
                }

                if (!map.CanFit(x, y, z, 16, false, false))
                {
                    continue;
                }

                trap.MoveToWorld(new Point3D(x, y, z), map);
                this.m_Traps.Add(trap);

                return;
            }

            trap.Delete();
        }
Example #25
0
 private void OnTrapTrigger(BaseTrap trap, GameObject go)
 {
     HookCalled("OnTrapTrigger");
 }
Example #26
0
        private object OnTrapTrigger(BaseTrap trap, GameObject obj)
        {
            if (!(trap is BearTrap) && !(trap is Landmine))
            {
                return(null);
            }
            BasePlayer target = obj.GetComponent <BasePlayer>();

            if (target != null)
            {
                if (permission.UserHasPermission(target.UserIDString, permissionNameADMIN))
                {
                    return(false);
                }
            }
            var player = FindPlayer(trap.OwnerID.ToString());

            if (target != null && player != null)
            {
                // Owner protection
                if (!hurtOwner)
                {
                    if (target == player)
                    {
                        if (permission.UserHasPermission(target.UserIDString, permissionNameOWNER))
                        {
                            return(false);
                        }
                    }
                }

                // Friends protection
                if (!hurtFriends)
                {
                    if (friendsEnabled)
                    {
                        if ((bool)Friends?.CallHook("AreFriends", target.userID, player.userID))
                        {
                            if (permission.UserHasPermission(player.UserIDString, permissionNameFRIENDS))
                            {
                                return(false);
                            }
                        }
                    }
                    if (rustIOEnabled)
                    {
                        if ((bool)RustIO?.Call("HasFriend", target.UserIDString, player.UserIDString))
                        {
                            if (permission.UserHasPermission(player.UserIDString, permissionNameFRIENDS))
                            {
                                return(false);
                            }
                        }
                    }
                }

                // Clanmates protection
                if (!hurtClanMates)
                {
                    if (clansEnabled)
                    {
                        if ((string)Clans?.Call("GetClanTag", target.UserIDString) == (string)Clans?.Call("GetClanTag", player.UserIDString))
                        {
                            if (permission.UserHasPermission(player.UserIDString, permissionNameCLAN))
                            {
                                return(false);
                            }
                        }
                        else if ((string)Clans?.Call("GetClanOf", target.UserIDString) == (string)Clans?.Call("GetClanOf", player.UserIDString))
                        {
                            if (permission.UserHasPermission(player.UserIDString, permissionNameCLAN))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            if (!(trap is BearTrap))
            {
                return(null);
            }
            if (player == null)
            {
                return(null);
            }
            if (permission.UserHasPermission(player.UserIDString, permissionName))
            {
                timer.Once(resetTime, () =>
                {
                    if (trap != null)
                    {
                        ((BearTrap)trap).Arm();
                    }
                });
            }
            return(null);
        }
Example #27
0
 private void OnTrapTrigger(BaseTrap trap, GameObject go)
 {
     HookCalled("OnTrapTrigger");
 }