示例#1
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;
                L2Object obj    = null;

                if (player.PBlockAct == 1)
                {
                    player.SendActionFailedAsync();
                    return;
                }

                if (_objectId == player.ObjectId)
                {
                    obj = player;
                }
                else
                {
                    if (L2World.GetObject(_objectId) != null)
                    {
                        obj = L2World.GetObject(_objectId);
                    }
                }

                if (obj == null)
                {
                    player.SendActionFailedAsync();
                    return;
                }

                //if (obj is L2Npc)
                //{
                //    if (((L2Npc)obj).Template._can_be_attacked == 0)
                //    {
                //        player.sendSystemMessage(144);//That is the incorrect target.
                //        player.sendActionFailed();
                //        return;
                //    }
                //}

                obj.OnForcedAttackAsync(player);
            });
        }
示例#2
0
        public override async Task RunImpl()
        {
            await Task.Run(() =>
            {
                L2Player player = _client.CurrentPlayer;
                L2Object obj    = null;

                if (_objectId == player.ObjectId)
                {
                    obj = player;
                }
                else
                {
                    if (L2World.GetObject(_objectId) != null)
                    {
                        obj = L2World.GetObject(_objectId);
                    }
                }
                //fixed nullreference exception when obj is null
                Log.Debug($"Action Requested with { Utilz.GetTypeLower(obj).ToString() }  of ID : { _objectId.ToString()}");

                if (obj == null)
                {
                    Log.Debug("Action Requested Failed");
                    player.SendActionFailedAsync();
                    return;
                }

                switch (_actionId)
                {
                case 0:
                    obj.OnActionAsync(player);
                    break;

                case 1:
                    obj.OnActionShiftAsync(player);
                    break;

                default:
                    player.SendActionFailedAsync();
                    break;
                }
            });
        }