Example #1
0
        /// <summary>
        /// 获取车辆id CPH值对关系
        /// </summary>
        /// <param name="message"></param>
        private void Handle5220Message(string message)
        {
            VehInfo obj = GetModelFromMsg <VehInfo>(message);

            if (!string.IsNullOrEmpty(obj.Clidlist) && !string.IsNullOrEmpty(obj.Cphlist))
            {
                string[] clidlst = obj.Clidlist.Split('_');
                string[] cphlst  = obj.Cphlist.Split('_');
                if (cphlst.Length != clidlst.Length || cphlst.Length == 0)
                {
                    LogUtility.DataLog.WriteLog(LogLevel.Info, $"值对关系不存在,内容:{message}", new RunningPlace("HandleMessage", "Handle5220Message"), "Running");
                }
                else
                {
                    Dictionary <string, string> lst = new Dictionary <string, string>();
                    for (int i = 0; i < cphlst.Length; i++)
                    {
                        if (!lst.ContainsKey(clidlst[i]))
                        {
                            lst.Add(clidlst[i], cphlst[i]);
                        }
                    }
                    Core.GetInstance().VehMap = lst;
                }
            }
        }
Example #2
0
        public bool gameStart()
        {       //We've started!
            _tickGameStart    = Environment.TickCount;
            _tickGameStarting = 0;

            //Scramble the teams!
            // ScriptHelpers.scrambleTeams(_arena, 2, true);

            //Spawn our flags!
            _arena.flagSpawn();

            //Let everyone know
            _arena.sendArenaMessage("Game has started!", _config.flag.resetBong);
            _gameWon = false;

            foreach (var s in _spawns)
            {
                foreach (var w in s._waypoints)
                {
                    VehInfo             wp            = _arena._server._assets.getVehicleByID(Convert.ToInt32(402));
                    Helpers.ObjectState waypointState = new Protocol.Helpers.ObjectState();
                    waypointState.positionX = (short)w.posX;
                    waypointState.positionY = (short)w.posY;
                    waypointState.positionZ = 0;
                    waypointState.yaw       = 0;
                    _arena.newVehicle(
                        wp,
                        _arena.Teams.ElementAt(7), null,
                        waypointState);
                }
            }

            return(true);
        }
Example #3
0
        public static void GetGrabRandomVehicle()
        {
            if (Client.Sync.Data.HasLocally(User.GetServerId(), "sellCarTaskName"))
            {
                Notification.SendWithTime("~g~Вы уже получили задание, угнать: " + Client.Sync.Data.GetLocally(User.GetServerId(), "sellCarTaskName"));
                return;
            }

            var pos     = GetEntityCoords(GetPlayerPed(-1), true);
            var vehicle = GetRandomVehicleInSphere(pos.X, pos.Y, pos.Z, 300f, 0, 0);
            var v       = new CitizenFX.Core.Vehicle(vehicle);

            switch (VehInfo.GetClassName(v.Model.Hash))
            {
            case "Emergency":
            case "Boats":
            case "Helicopters":
            case "Planes":
                GetGrabRandomVehicle();
                return;
            }

            Notification.SendWithTime("~g~Вам нужно угнать: " + v.DisplayName);
            Client.Sync.Data.SetLocally(User.GetServerId(), "sellCarTaskHash", v.Model.Hash);
            Client.Sync.Data.SetLocally(User.GetServerId(), "sellCarTaskName", v.DisplayName);
        }
        public bool canRollOver(int x, int y, VehInfo type)
        {
            LvlInfo level = _arena._server._assets.Level;

            bool blocked = level.isTileBlocked(x, y, type);

            if (blocked)
            {
                x /= 16;
                y /= 16;
                int   phy  = level.Tiles[y * level.Width + x].Physics;
                short low  = level.PhysicsLow[phy];
                short high = level.PhysicsHigh[phy];

                //Typical man vehicle: LowZ = 0 HighZ = 55
                //Physic (Green): LowZ = 0 HighZ = 16

                //Can we pass under or over?
                if (_state.positionZ > low)
                {
                    blocked = false;   //Not blocked
                }
            }
            return(blocked);
        }
Example #5
0
        ///////////////////////////////////////////////////
        // Member Classes
        ///////////////////////////////////////////////////
        #region Member Classes

        #endregion

        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Vehicle(VehInfo type, Arena arena)
        {       //Populate variables
            _type  = type;
            _arena = arena;

            _childs = new List <Vehicle>();

            _state = new Helpers.ObjectState();
        }
Example #6
0
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Vehicle(VehInfo type, Helpers.ObjectState state, Arena arena)
        {       //Populate variables
            _type  = type;
            _arena = arena;

            _childs = new List <Vehicle>();

            _state     = state;
            _attackers = new List <Player>();
        }
        ///////////////////////////////////////////////////
        // Member Classes
        ///////////////////////////////////////////////////
        #region Member Classes

        #endregion

        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Vehicle(VehInfo type, Arena arena)
        {       //Populate variables
            _type  = type;
            _arena = arena;

            _childs = new List <Vehicle>();

            _state     = new Helpers.ObjectState();
            _attackers = new List <Player>();

            _abstract = new VehicleAbstract(this);
        }
Example #8
0
        private static async Task SapdRadar()
        {
            if (User.IsLogin() && (IsHudPreferenceSwitchedOn() || Screen.Hud.IsVisible))
            {
                if (IsShowRadar)
                {
                    var veh = GetVehiclePedIsUsing(PlayerPedId());
                    var v   = new CitizenFX.Core.Vehicle(veh);

                    if (!_isFreezeRadar)
                    {
                        var coordA   = GetOffsetFromEntityInWorldCoords(veh, 0.0f, 1.0f, 1.0f);
                        var coordB   = GetOffsetFromEntityInWorldCoords(veh, 0.0f, 105.0f, 0.0f);
                        var frontcar = StartShapeTestCapsule(coordA.X, coordA.Y, coordA.Z, coordB.X, coordB.Y, coordB.Z, 3.0f, 10, veh, 7);
                        GetShapeTestResult(frontcar, ref _hit1, ref _endCoords1, ref _surfaceNormal1, ref _entityHit1);

                        if (IsEntityAVehicle(_entityHit1))
                        {
                            _radarInfoFront = $"{Vehicle.GetVehicleNumber(_entityHit1)} | {GetDisplayNameFromVehicleModel((uint) GetEntityModel(_entityHit1))} | {Math.Round(GetEntitySpeed(_entityHit1) * 2.23693629, 0)} MP/H";
                        }

                        var bcoordB = GetOffsetFromEntityInWorldCoords(veh, 0.0f, -105.0f, 0.0f);
                        var rearcar = StartShapeTestCapsule(coordA.X, coordA.Y, coordA.Z, bcoordB.X, bcoordB.Y, bcoordB.Z, 3.0f, 10, veh, 7);
                        GetShapeTestResult(rearcar, ref _hit2, ref _endCoords2, ref _surfaceNormal2, ref _entityHit2);

                        if (IsEntityAVehicle(_entityHit2))
                        {
                            _radarInfoBack = $"{Vehicle.GetVehicleNumber(_entityHit2)} | {GetDisplayNameFromVehicleModel((uint) GetEntityModel(_entityHit2))} | {Math.Round(GetEntitySpeed(_entityHit2) * 2.23693629, 0)} MP/H";
                        }
                    }

                    var tag = User.Data.tag != "" && User.IsGos() ? User.Data.tag.ToUpper() + " | " : "";
                    DrawRectangle(371, 317, 350, 200, 0, 0, 0, 150, 2, 2);
                    DrawText($"{tag}№{User.Data.id}", 363, 313, 0.6f, 255, 255, 255, 255, 4, 0, false, false, 0, 2, 2);
                    DrawRectangle(371, 317, 350, 50, 3, 169, 244, 150, 2, 2);
                    DrawText($"{VehInfo.GetDisplayName(v.Model.Hash).ToUpper()} | {Vehicle.GetVehicleNumber(veh)} | СИРЕНА: {(IsVehicleSirenOn(veh) ? "ВКЛ" : "ВЫКЛ")} | {_speed} MP/H", 363, 267, 0.4f, 3, 155, 229, 255, 4, 0, false, false, 0, 2, 2);
                    DrawRectangle(371, 267, 350, 30, 2, 119, 189, 150, 2, 2);
                    DrawText("ПЕРЕДНИЙ РАДАР", 363, 234, 0.3f, 255, 255, 255, 150, 4, 0, false, false, 0, 2, 2);
                    DrawText("ЗАДНИЙ РАДАР", 362, 175, 0.3f, 255, 255, 255, 150, 4, 0, false, false, 0, 2, 2);
                    DrawText(_radarInfoFront, 362, 217, 0.5f, 255, 255, 255, 255, 4, 0, false, false, 0, 2, 2);
                    DrawText(_radarInfoBack, 361, 158, 0.5f, 255, 255, 255, 255, 4, 0, false, false, 0, 2, 2);
                    DrawRectangle(361, 180, 330, 1, 255, 255, 255, 255, 2, 2);
                }

                if (!IsPedInAnyVehicle(GetPlayerPed(-1), true) && IsShowRadar)
                {
                    _radarInfoFront = "В ожидании...";
                    _radarInfoBack  = "В ожидании...";
                    IsShowRadar     = false;
                }
            }
        }
Example #9
0
        /// <summary>
        /// Returns a random zombie type playable by the player
        /// </summary>
        static public VehInfo getPlayableZombie(Player player)
        {
            int     vehid = getPlayableZombieID(player);
            VehInfo veh   = AssetManager.Manager.getVehicleByID(vehid);

            if (veh == null)
            {
                veh = AssetManager.Manager.getVehicleByID(c_fallbackVehicle);
                Log.write(TLog.Error, "getPlayableZombie: Attempted to choose non-existent vehicle " + vehid);
            }

            return(veh);
        }
Example #10
0
        /// <summary>
        /// Adds the given player to the team and notifies others
        /// </summary>
        public void addPlayer(Player player, bool manualJoin)
        {       //Sanity checks
            if (player._bIngame && player._team == this)
            {
                Log.write(TLog.Warning, "Attempted to add player to his own team. {0}", player);
                return;
            }

            //Have him lose his current team
            if (player._team != null)
            {
                player._team.lostPlayer(player);
            }

            //Set his new team!
            player._team = this;

            //Welcome him in
            if (!_players.Contains(player))
            {
                _players.Add(player);
            }

            //Do we need to notify, or is this an initial team?
            if (player._bIngame)
            {
                //Let everyone know
                Helpers.Player_SetTeam(_arena.Players, player, this);
            }

            player.sendMessage(0, "Team joined: " + _name);

            //Set relative vehicle if required, no need for any if statement here :]
            VehInfo vehicle = _server._assets.getVehicleByID(player.getDefaultVehicle().Id + _relativeVehicle);

            player.setDefaultVehicle(vehicle);

            //If he isn't a spectator, trigger the event too
            if (!player.IsSpectator)
            {
                if (manualJoin)
                {
                    Logic_Assets.RunEvent(player, _server._zoneConfig.EventInfo.manualJoinTeam);
                }
                else
                {
                    Logic_Assets.RunEvent(player, _server._zoneConfig.EventInfo.joinTeam);
                }
            }
        }
Example #11
0
        public static bool joinTeam(this Player player, Team team)
        {
            //Sanity checks
            if (player._occupiedVehicle == null)
            {
                Log.write(TLog.Warning, "Attempted to unspectate with no spectator vehicle. {0}", player);
                return(false);
            }

            //Make sure our vehicle is a spectator mode vehicle
            if (player._occupiedVehicle._type.Type != VehInfo.Types.Spectator)
            {
                Log.write(TLog.Warning, "Attempted to unspectate with non-spectator vehicle. {0}", player);
                return(false);
            }

            //Reset leftover variables
            player._deathTime     = 0;
            player._lastMovement  = Environment.TickCount;
            player._maxTimeCalled = false;

            //Throw ourselves onto our new team!
            team.addPlayer(player);

            //Destroy our spectator vehicle
            player._occupiedVehicle.destroy(true);
            player._bSpectator = false;

            //Set relative vehicle if required, no need for any if statement here :]
            VehInfo vehicle = player._server._assets.getVehicleByID(player.getDefaultVehicle().Id + player._server._zoneConfig.teams[team._id].relativeVehicle);

            player.setDefaultVehicle(vehicle);

            //Run the exit spec event
            Logic_Assets.RunEvent(player, player._server._zoneConfig.EventInfo.exitSpectatorMode);

            //Make sure the arena knows we've entered
            player._arena.playerEnter(player);

            if (player.ZoneStat1 > player._server._zoneConfig.bounty.start)
            {
                player.Bounty = player.ZoneStat1;
            }
            else
            {
                player.Bounty = player._server._zoneConfig.bounty.start;
            }

            return(true);
        }
Example #12
0
        //Creates a turrent, offsets are from HQ
        public void createVehicle(int id, int x_offset, int y_offset, Team botTeam)
        {
            VehInfo vehicle = _arena._server._assets.getVehicleByID(Convert.ToInt32(id));

            Helpers.ObjectState newState = new Protocol.Helpers.ObjectState();
            newState.positionX = Convert.ToInt16(_state.positionX + x_offset);
            newState.positionY = Convert.ToInt16(_state.positionY + y_offset);
            newState.positionZ = _state.positionZ;
            newState.yaw       = _state.yaw;

            _arena.newVehicle(
                vehicle,
                botTeam, null,
                newState);
        }
Example #13
0
        private void spawnDynamicMap()
        {
            VehInfo team1Home = _arena._server._assets.getVehicleByID(Convert.ToInt32(403));

            Helpers.ObjectState t1HomeState = new Protocol.Helpers.ObjectState();
            t1HomeState.positionX = (short)team1.x1;
            t1HomeState.positionY = (short)team1.y1;
            _arena.newVehicle(
                team1Home,
                _arena.Teams.ElementAt(1), null,
                t1HomeState, null);

            VehInfo team1Nme = _arena._server._assets.getVehicleByID(Convert.ToInt32(404));

            Helpers.ObjectState t1NmeState = new Protocol.Helpers.ObjectState();
            t1NmeState.positionX = (short)team2.x2;
            t1NmeState.positionY = (short)team2.y2;
            _arena.newVehicle(
                team1Nme,
                _arena.Teams.ElementAt(1), null,
                t1NmeState, null);

            VehInfo team2Home = _arena._server._assets.getVehicleByID(Convert.ToInt32(403));

            Helpers.ObjectState t2HomeState = new Protocol.Helpers.ObjectState();
            t2HomeState.positionX = (short)team2.x1;
            t2HomeState.positionY = (short)team2.y1;
            _arena.newVehicle(
                team2Home,
                _arena.Teams.ElementAt(2), null,
                t2HomeState, null);

            VehInfo team2Nme = _arena._server._assets.getVehicleByID(Convert.ToInt32(404));

            Helpers.ObjectState t2NmeState = new Protocol.Helpers.ObjectState();
            t2NmeState.positionX = (short)team1.x2;
            t2NmeState.positionY = (short)team1.y2;
            _arena.newVehicle(
                team2Nme,
                _arena.Teams.ElementAt(2), null,
                t2NmeState, null);
        }
Example #14
0
        public bool canBuildInArea(Player player, VehInfo vehicle)
        {
            bool bSuccess = false;

            if (!isAreaOpen(player._state.positionX, player._state.positionY, vehicle.PhysicalRadius))
            {
                player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                bSuccess = false;
            }
            else if (!powerStationInArea(player._state.positionX, player._state.positionY))
            {
                player.sendMessage(-1, "Cannot construct building, too far from a power station.");
                bSuccess = false;
            }
            else
            {
                //Building...
                bSuccess = true;
            }

            return(bSuccess);
        }
Example #15
0
        private void hideLootBoxes(int count, List <short> spawnPoints)
        {
            VehInfo box = AssetManager.Manager.getVehicleByID(413);

            foreach (short posX in spawnPoints)
            {
                short posY = 1744;

                for (int i = 0; i < count; i++)
                {
                    //Generate some random coordinates
                    short pX       = 0;
                    short pY       = 0;
                    int   attempts = 0;
                    for (; attempts < 30; attempts++)
                    {
                        pX = posX;
                        pY = posY;

                        Helpers.randomPositionInArea(_arena, 2500, ref pX, ref pY);

                        //Is it blocked?
                        if (_arena.getTile(pX, pY).Blocked)
                        {
                            //Try again
                            continue;
                        }

                        Helpers.ObjectState newState = new Helpers.ObjectState();
                        newState.positionX = pX;
                        newState.positionY = pY;
                        _arena.newVehicle(box, _arena.getTeamByName("spec"), null, newState);
                        break;
                    }
                }
            }
        }
Example #16
0
        private static async Task TimeSync()
        {
            if (User.IsLogin() && (IsHudPreferenceSwitchedOn() || Screen.Hud.IsVisible))
            {
                if (IsPedInAnyVehicle(PlayerPedId(), true))
                {
                    var velocity = GetEntityVelocity(GetVehiclePedIsUsing(PlayerPedId()));
                    var speed    = Math.Sqrt(velocity.X * velocity.X +
                                             velocity.Y * velocity.Y +
                                             velocity.Z * velocity.Z);

                    /*var vehId = Vehicle.GetVehicleIdByNetId(VehToNet(GetVehiclePedIsUsing(PlayerPedId())));
                     *
                     * var indicator = "~g~";
                     *
                     * if (vehId != -1)
                     * {
                     *  var fuelIndicator = Convert.ToInt32((Vehicle.VehicleInfoGlobalDataList[vehId].Fuel / Vehicle.VehicleInfoGlobalDataList[vehId].FullFuel) * 100);
                     *  if (fuelIndicator < 61 && fuelIndicator > 40)
                     *      indicator = "~y~";
                     *  else if(fuelIndicator < 41 && fuelIndicator > 20)
                     *      indicator = "~o~";
                     *  else if(fuelIndicator < 21 && fuelIndicator > 1)
                     *      indicator = "~r~";
                     *  else if(fuelIndicator < 2)
                     *      indicator = "~u~";
                     * }*/

                    _speed = (int)Math.Round(speed * 2.23693629, 0);

                    var vehId = Vehicle.GetVehicleIdByNumber(Vehicle.GetVehicleNumber(GetVehiclePedIsUsing(PlayerPedId())));
                    if (vehId != -1)
                    {
                        _fuel = Convert.ToInt32(Vehicle.VehicleInfoGlobalDataList[vehId].Fuel) + " Л";
                    }
                    else if (VehInfo.Get(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))).FullFuel == 1)
                    {
                        _fuel = "ЭЛЕКТРО";
                    }
                    else
                    {
                        _fuel = VehInfo.Get(GetEntityModel(GetVehiclePedIsUsing(PlayerPedId()))).FullFuel + " Л";
                    }

                    /*DrawRectangle(319, 166, 180, 1, 255, 255, 255, 255, 2);
                     * DrawText($"{indicator}*", 319, 205, 0.9f, 255, 255, 255, 255, 4, 0, false, true, 0, 2);
                     * DrawText($"I {_speed} MP/H", 339, 208, 0.6f, 255, 255, 255, 255, 4, 0, false, true, 0, 2);*/
                }

                //DrawText("Appi ~y~" + _rpg, 0, 10, 0.5f, 255, 255, 255, 255, 1, 1, true, true, 0, 0, 1);

                var rightOffset = 0;
                if (Main.MaxPlayers > 32)
                {
                    rightOffset = 150;
                }

                if (User.Data.jail_time > 0)
                {
                    DrawText(User.Data.jail_time + "сек. | " + Weather.FullRealDateTime + " | " + "ID:" + User.Data.id + " | " + Main.ServerName, 130 + rightOffset, 8, 0.3f, 255, 255, 255, 180, 0, 2, false, false, 0, 0, 2);
                }
                else if (NoClip.NoClipEnabled)
                {
                    DrawText(NoClip.Speeds[NoClip.CurrentSpeed] + " | " + Weather.FullRealDateTime + " | " + "ID:" + User.Data.id + " | " + Main.ServerName, 130 + rightOffset, 8, 0.3f, 255, 255, 255, 180, 0, 2, false, false, 0, 0, 2);
                }
                else
                {
                    DrawText(Weather.FullRealDateTime + " | " + "ID:" + User.Data.id + " | " + Main.ServerName, 130 + rightOffset, 8, 0.3f, 255, 255, 255, 180 + rightOffset, 0, 2, false, false, 0, 0, 2);
                }

                /*
                 * if (User.Data.money < 0)
                 *  DrawText("$" + User.Data.money.ToString("#,#"), 15, 50, 0.6f, 244, 67, 54, 255, 7, 2, false, true, 0, 0, 2);
                 * else if (User.Data.money == 0)
                 *  DrawText("$0", 15, 50, 0.6f, 244, 67, 54, 255, 7, 2, false, true, 0, 0, 2);
                 * else
                 *  DrawText("$" + User.Data.money.ToString("#,#"), 15, 50, 0.6f, 115, 186, 131, 255, 7, 2, false, true, 0, 0, 2);
                 * if (User.Data.item_clock)
                 * {
                 *  //DrawText(UpdateDirectionText(), 347, 72, 1, 255, 255, 255, 255, 4, 1, false, true, 0, 2);
                 *  DrawText("|", 374, 72, 1, 255, 255, 255, 255, 4, 0, false, true, 0, 2);
                 *  DrawText(_zone, 391, 65, 0.4f, 241, 196, 15, 255, 4, 0, false, true, 0, 2);
                 *  DrawText(_street, 390, 42, 0.4f, 255, 255, 255, 255, 4, 0, false, true, 0, 2);
                 *  DrawRectangle(319, 67, 180, 1, 255, 255, 255, 255, 2);
                 *  DrawText("Температура воздуха: ~w~" + Weather.Temp + '°', 319, 100, 0.4f, 241, 196, 15, 255, 4, 0, false, true, 0, 2);
                 *  DrawRectangle(319, 102, 180, 1, 255, 255, 255, 255, 2);
                 *  DrawText(World.CurrentDayTime.Hours.ToString("D2") + ":" + World.CurrentDayTime.Minutes.ToString("D2") + " | " + Weather.Day.ToString("D2") + "/" + Weather.Month.ToString("D2") + "/" + Weather.Year.ToString("D2"), 319, 142, 0.6f, 255, 255, 255, 255, 4, 0, false, true, 0, 2);
                 *  DrawText(Weather.DayName, 319, 165, 0.4f, 241, 196, 15, 255, 4, 0, false, true, 0, 2);
                 *
                 *  //DrawText("Сытость: ~g~" + User.Data.eat_level / 1000 + "%", 10, 545, 0.40f, 255, 255, 255, 255, 4, 0, true, true, 0);
                 *  //DrawText("Жажда: ~g~" + User.Data.water_level / 100 + "%", 10, 575, 0.40f, 255, 255, 255, 255, 4, 0, true, true, 0);
                 * }
                 */
                TimerBarPool.Draw();

                //DrawText("Громкость: ~g~" + User.VoiceString, 10, 605, 0.40f, 255, 255, 255, 255, 4, 0, true, true, 0);
                //DrawText("Иммунитет: ~g~" + User.Data.health_level + "%", 10, 605, 0.40f, 255, 255, 255, 255, 4, 0, true, true, 0);
                //DrawText("Температура тела: ~g~" + Math.Round(User.Data.temp_level, 1) + "°", 10, 635, 0.40f, 255, 255, 255, 255, 4, 0, true, true, 0);
            }
        }
Example #17
0
        /// <summary>
        /// Looks after the bot's functionality
        /// </summary>
        public virtual bool poll()
        {       //Calculate our delta time..
            int tickCount = Environment.TickCount;
            int delta     = tickCount - _tickLastPoll;

            //Don't need to update too much
            if (delta < 0)
            {
                return(false);
            }

            _tickLastPoll = tickCount;

            //If it's a ridiculous delta, ignore it
            if (delta > 600)
            {
                Log.write(TLog.Warning, "Encountered excessive bot delta of {0}", delta);
                destroy(true);
                return(false);
            }

            //Are we dead?
            if (IsDead)
            {
                //Drop our items
                VehInfo  vehicle = _arena._server._assets.getVehicleByID(_type.Id);
                ItemInfo item    = _arena._server._assets.getItemByID(vehicle.DropItemId);
                if (item != null)
                {
                    _arena.itemSpawn(item, (ushort)vehicle.DropItemQuantity, _state.positionX, _state.positionY, null);
                }

                //Should we remove ourself from the world?
                if (_type.RemoveDeadTimer != 0 && _tickDead != 0 &&
                    tickCount - _tickDead > (_type.RemoveDeadTimer * 1000))
                {
                    destroy(true);
                }
                else
                {                       //Keep sending 'corpse' updates
                    if (tickCount - _tickLastUpdate > 1500)
                    {
                        _tickLastUpdate = tickCount;
                        return(true);
                    }
                }
            }
            else
            {
                //Allow our controller to update our vehicle state
                _movement.updateState(delta);

                if (_itemUseID == 0)
                {
                    if (tickCount - _tickLastUpdate > 200)
                    {
                        _tickLastUpdate = tickCount;
                        return(true);
                    }
                    return(false);
                }
                return(true);
            }

            return(false);
        }
 public ZombieType(Type _classType, VehInfo _vehicleType)
 {
     vehicleType = _vehicleType;
     classType   = _classType;
 }
Example #19
0
        /// <summary>
        /// Creates and adds a new bot vehicle to the arena
        /// </summary>
        public Bot newBot(Type botType, VehInfo type, Team team, Player owner, Helpers.ObjectState state, params object[] args)
        {       //Is this bot type compatible?
            if (!typeof(Bot).IsAssignableFrom(botType))
            {
                Log.write(TLog.Error, "Unable to infer bot type from type '{0}'.", botType);
                return(null);
            }

            //Sanity checks
            VehInfo.Car carType = type as VehInfo.Car;
            if (carType == null)
            {
                Log.write(TLog.Error, "Bots can only be created using Car vehicles.");
                return(null);
            }

            //Too many vehicles?
            if (_vehicles.Count == maxVehicles)
            {
                Log.write(TLog.Warning, "Vehicle list full.");
                return(null);
            }

            //We want to continue wrapping around the vehicleid limits
            //looking for empty spots.
            ushort vk;

            for (vk = _lastVehicleKey; vk <= UInt16.MaxValue; ++vk)
            {   //If we've reached the maximum, wrap around
                if (vk == UInt16.MaxValue)
                {
                    vk = 5001;
                    continue;
                }

                //Does such a vehicle exist?
                if (_vehicles.getObjByID(vk) != null)
                {
                    continue;
                }

                //We have a space!
                break;
            }

            _lastVehicleKey = (ushort)(vk + 1);

            //Create our vehicle class
            Bot newBot;

            Helpers.ObjectState newState = new Helpers.ObjectState();

            if (state != null)
            {
                newState.positionX = state.positionX;
                newState.positionY = state.positionY;
                newState.positionZ = state.positionZ;
                newState.yaw       = state.yaw;

                if (args != null && args.Length > 0)
                {       //Put together a new argument list
                    object[] arguments = new object[3 + args.Length];

                    arguments[0] = carType;
                    arguments[1] = newState;
                    arguments[2] = this;

                    Array.Copy(args, 0, arguments, 3, args.Length);

                    newBot = (Bot)Activator.CreateInstance(botType, arguments);
                }
                else
                {
                    newBot = (Bot)Activator.CreateInstance(botType, carType, newState, this);
                }
            }
            else
            {
                if (args != null && args.Length > 0)
                {       //Put together a new argument list
                    object[] arguments = new object[2 + args.Length];

                    arguments[0] = carType;
                    arguments[1] = this;

                    Array.Copy(args, 0, arguments, 2, args.Length);

                    newBot = (Bot)Activator.CreateInstance(botType, arguments);
                }
                else
                {
                    newBot = (Bot)Activator.CreateInstance(botType, carType, this);
                }
            }

            if (newBot == null)
            {
                Log.write(TLog.Error, "Error while instancing bot type '{0}'", botType);
                return(null);
            }

            newBot._arena = this;
            newBot._id    = vk;

            newBot._team         = team;
            newBot._creator      = owner;
            newBot._tickCreation = Environment.TickCount;

            newBot.assignDefaultState();

            //This uses the new ID automatically
            _vehicles.Add(newBot);
            _bots.Add(newBot);
            _botsInArena++;

            //Notify everyone of the new vehicle
            Helpers.Object_Vehicles(Players, newBot);
            return(newBot);
        }
Example #20
0
        public static void SellVehicle(CitizenFX.Core.Vehicle veh)
        {
            if (Weather.Hour < 22 && Weather.Hour > 4)
            {
                Notification.SendWithTime("~r~Доступно только с 22 до 4 утра");
                return;
            }

            if (User.Data.sell_car_time > 0)
            {
                Notification.SendWithTime("~r~Вы не можете сейчас сбыть транспорт");
                Debug.WriteLine("sell_car_time: " + User.Data.sell_car_time);
                return;
            }

            int money = 100;

            if (Client.Sync.Data.HasLocally(User.GetServerId(), "sellCarTaskName"))
            {
                if ((string)Client.Sync.Data.GetLocally(User.GetServerId(), "sellCarTaskName") == veh.DisplayName)
                {
                    Client.Sync.Data.ResetLocally(User.GetServerId(), "sellCarTaskHash");
                    Client.Sync.Data.ResetLocally(User.GetServerId(), "sellCarTaskName");

                    money += 250;

                    switch (VehInfo.GetClassName(veh.Model.Hash))
                    {
                    case "Sports Classics":
                        money += 450;
                        break;

                    case "Sports":
                        money += 320;
                        break;

                    case "Super":
                        money += 280;
                        break;

                    case "SUVs":
                    case "Muscle":
                    case "Off-Road":
                        money += 250;
                        break;
                    }

                    veh.Delete();

                    User.AddCashMoney(money);
                    Notification.SendWithTime("~g~Вы заработали: $" + money);

                    User.Data.sell_car_time = 15;
                    Client.Sync.Data.Set(User.GetServerId(), "sell_car_time", User.Data.sell_car_time);
                    return;
                }
            }

            switch (VehInfo.GetClassName(veh.Model.Hash))
            {
            case "Emergency":
            case "Boats":
            case "Helicopters":
            case "Planes":
                Notification.SendWithTime("~r~Мы такое не принимаем");
                return;

            case "Sports Classics":
                money += 250;
                break;

            case "Sports":
                money += 220;
                break;

            case "Super":
                money += 180;
                break;

            case "SUVs":
            case "Muscle":
            case "Off-Road":
                money += 150;
                break;
            }

            veh.Delete();

            User.AddCashMoney(money);
            Notification.SendWithTime("~g~Вы заработали: $" + money);

            var pPos = GetEntityCoords(GetPlayerPed(-1), true);

            Main.SaveLog("Grab", $"[GRAB_CAR] {User.Data.rp_name} | {pPos.X} {pPos.Y} {pPos.Z} | ${money} | {VehInfo.GetDisplayName(veh.Model.Hash)} | {VehInfo.GetClassName(veh.Model.Hash)}");

            User.Data.sell_car_time = 30;
            Client.Sync.Data.Set(User.GetServerId(), "sell_car_time", User.Data.sell_car_time);
        }
Example #21
0
 /// <summary>
 /// Creates and adds a new vehicle to the arena
 /// </summary>
 public Vehicle newVehicle(VehInfo type, Team team, Player creator, Helpers.ObjectState state, Action <Vehicle> setupCB)
 {
     return(newVehicle(type, team, creator, state, setupCB, null));
 }
Example #22
0
 /// <summary>
 /// Creates and adds a new vehicle to the arena
 /// </summary>
 public Vehicle newVehicle(VehInfo type, Team team, Player creator, Helpers.ObjectState state)
 {       //Redirect
     return(newVehicle(type, team, creator, state, null));
 }
Example #23
0
 /// <summary>
 /// Creates and adds a new vehicle to the arena
 /// </summary>
 public Vehicle newVehicle(VehInfo type, Team team, Player creator)
 {       //Redirect
     return(newVehicle(type, team, creator, null, null));
 }
Example #24
0
        /// <summary>
        /// '
        /// Allows the script to maintain itself
        /// </summary>
        public override bool poll()
        {
            if (bOverriddenPoll)
            {
                return(base.poll());
            }

            //Dead? Do nothing
            if (IsDead)
            {
                steering.steerDelegate = null;
                return(base.poll());
            }

            if (!_arena._bGameRunning)
            {
                base.destroy(false, true);
            }

            int now = Environment.TickCount;

            //Radar Dot
            if (now - _tickLastRadarDot >= 900)
            {
                _tickLastRadarDot = now;
                IEnumerable <Player> enemies = _arena.Players.Where(p => p._team != _team);
                // Helpers.Player_RouteExplosion(_team.ActivePlayers, 1131, _state.positionX, _state.positionY, 0, 0, 0);
                // Helpers.Player_RouteExplosion(enemies, 1130, _state.positionX, _state.positionY, 0, 0, 0);
            }

            if (now - _tickSuppliesDropped >= 4350 && !_bDropped && _tickSuppliesDropped != 0)
            {
                VehInfo             supplyVehicle = AssetManager.Manager.getVehicleByID(405);
                Helpers.ObjectState objState      = new Helpers.ObjectState();

                objState.positionX = _targetLocation._state.positionX;
                objState.positionY = _targetLocation._state.positionY;

                Computer   newVehicle = _arena.newVehicle(supplyVehicle, _team, null, objState) as Computer;
                SupplyDrop newDrop    = new SupplyDrop(_team, newVehicle, objState.positionX, objState.positionY);
                _script._supplyDrops.Add(newDrop);

                _team.sendArenaMessage(String.Format("&Supplies have been dropped at {0}.", newVehicle._state.letterCoord()), 4);
                _bDropped = true;
                //Get rid of our marker
                _supplyMarker.destroy(false);
            }


            if (!_bDropped)
            {
                bool onSite = false;

                //Get to landing zone
                if (Helpers.distanceTo(_targetLocation._state, _state) > 45)
                {
                    steering.steerDelegate = steerForFollowOwner;
                }
                else
                {
                    steering.freezeMovement(10000);
                    onSite = true;
                }

                //Can we drop?
                if (onSite && !_dropItemFired)
                {
                    _tickSuppliesDropped = now;
                    _dropItemFired       = true;

                    Helpers.Player_RouteExplosion(_arena.Players, 3215, _targetLocation._state.positionX,
                                                  _targetLocation._state.positionY, 800, 0, 0);
                }
            }
            else
            {
                _targetLocation = _spawnMarker;
                bool onSite = false;

                //Get to landing zone
                if (Helpers.distanceTo(_targetLocation._state, _state) > 45)
                {
                    steering.steerDelegate = steerForFollowOwner;
                }
                else
                {
                    steering.freezeMovement(5000);
                    onSite = true;
                }

                //Can we drop?
                if (onSite)
                {
                    base.destroy(true);
                }
            }

            //Handle normal functionality
            return(base.poll());
        }
 public ZombieType(Type _classType, VehInfo _vehicleType, Action <ZombieBot> _zombieSetup)
 {
     vehicleType = _vehicleType;
     classType   = _classType;
     zombieSetup = _zombieSetup;
 }
Example #26
0
        public bool playerMakeVehicle(Player player, ItemInfo.VehicleMaker item, short posX, short posY)
        {
            int     count    = _arena.Vehicles.Count(veh => veh._type.Id == item.vehicleID);
            bool    bSuccess = false;
            VehInfo vehicle  = AssetManager.Manager.getVehicleByID(item.vehicleID);

            switch (item.vehicleID)
            {
            //Command Center
            case 414:
            {
                if (count > 0)
                {
                    player.sendMessage(-1, "You may only have one active Command Center.");
                    player.syncState();
                    bSuccess = false;
                }
                else if (!canBuildInArea(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //Power Station
            case 423:
            {
                if (!canBuildInArea(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //Catch all
            default:
            {
                if (!canBuildInArea(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else if (!powerStationInArea(posX, posY))
                {
                    player.sendMessage(-1, "Cannot construct building, too far from a power station.");
                    bSuccess = false;
                }
                else
                {
                    //Building...
                    bSuccess = true;
                }
            }
            break;
            }
            //Give them back their kit if it failed.
            if (!bSuccess)
            {
                player.inventoryModify(item, 1);
            }

            return(bSuccess);
        }
Example #27
0
        //Spawns all the HQs, inhibitors, jungle spawns, towers, and waypoints
        public void spawnAllVehs()
        {
            //Spawn all jungle locations
            foreach (KeyValuePair <int, jungleObject> obj in _jungle)
            {
                VehInfo             jungle        = _arena._server._assets.getVehicleByID(Convert.ToInt32(_jungleVehId));
                Helpers.ObjectState waypointState = new Protocol.Helpers.ObjectState();
                waypointState.positionX = obj.Value.getX();
                waypointState.positionY = obj.Value.getY();
                waypointState.positionZ = 0;
                waypointState.yaw       = 0;
                _arena.newVehicle(
                    jungle,
                    _arena.Teams.ElementAt(2), null,
                    waypointState);
            }

            //Spawn all waypoints
            foreach (KeyValuePair <int, wayPoint> obj in _topWaypoints)
            {
                VehInfo             waypoint      = _arena._server._assets.getVehicleByID(Convert.ToInt32(_waypointVehId));
                Helpers.ObjectState waypointState = new Protocol.Helpers.ObjectState();
                waypointState.positionX = obj.Value.getX();
                waypointState.positionY = obj.Value.getY();
                waypointState.positionZ = 0;
                waypointState.yaw       = 0;
                _arena.newVehicle(
                    waypoint,
                    obj.Value.getOwner(), null,
                    waypointState);
            }
            foreach (KeyValuePair <int, wayPoint> obj in _bottomWaypoints)
            {
                VehInfo             waypoint      = _arena._server._assets.getVehicleByID(Convert.ToInt32(_waypointVehId));
                Helpers.ObjectState waypointState = new Protocol.Helpers.ObjectState();
                waypointState.positionX = obj.Value.getX();
                waypointState.positionY = obj.Value.getY();
                waypointState.positionZ = 0;
                waypointState.yaw       = 0;
                _arena.newVehicle(
                    waypoint,
                    obj.Value.getOwner(), null,
                    waypointState);
            }

            //Spawn all the inhibitors
            foreach (KeyValuePair <int, inhibObject> obj in _inhibitors)
            {
                VehInfo             vehicle  = _arena._server._assets.getVehicleByID(Convert.ToInt32(_inhibVehId));
                Helpers.ObjectState newState = new Protocol.Helpers.ObjectState();
                newState.positionX = obj.Value.getX();
                newState.positionY = obj.Value.getY();
                newState.positionZ = 0;
                newState.yaw       = 0;

                obj.Value.setExists(true);


                _arena.newVehicle(
                    vehicle,
                    obj.Value.getTeam(), null,
                    newState);
            }
            //Spawn all the towers
            foreach (KeyValuePair <int, towerObject> obj in _towers)
            {
                VehInfo             vehicle  = _arena._server._assets.getVehicleByID(Convert.ToInt32(_towerVehId));
                Helpers.ObjectState newState = new Protocol.Helpers.ObjectState();
                newState.positionX = obj.Value.getX();
                newState.positionY = obj.Value.getY();
                newState.positionZ = 0;
                newState.yaw       = 0;

                obj.Value.setExists(true);
                Tower tower = _arena.newVehicle(
                    vehicle,
                    obj.Value.getTeam(), null,
                    newState, null, typeof(Tower)) as Tower;
                tower._moba = this;
            }

            //Reset everyones level(bounty) and experience
            foreach (Player p in _arena.Players.ToList())
            {
                p._level     = 1;
                p.Experience = 0;
                p.Bounty     = 1;
                p.syncState();
            }

            //Spawn all the HQs
            VehInfo HQ = _arena._server._assets.getVehicleByID(Convert.ToInt32(_hqVehId));

            Helpers.ObjectState hqState = new Protocol.Helpers.ObjectState();
            hqState.positionX = (short)_hqSpawnX1;
            hqState.positionY = (short)_hqSpawny1;
            _arena.newVehicle(
                HQ,
                _arena.Teams.ElementAt(0), null,
                hqState, null);
            hqState.positionX = (short)_hqSpawnX2;
            hqState.positionY = (short)_hqSpawny2;
            _arena.newVehicle(
                HQ,
                _arena.Teams.ElementAt(1), null,
                hqState, null);
        }
Example #28
0
        public bool playerMakeVehicle(Player player, ItemInfo.VehicleMaker item, short posX, short posY)
        {
            int       count         = _arena.Vehicles.Count(veh => veh._type.Id == item.vehicleID);
            int       totalCount    = _structures.Count;
            bool      bSuccess      = false;
            VehInfo   vehicle       = AssetManager.Manager.getVehicleByID(item.vehicleID);
            Structure commandCenter = _structures.Values.FirstOrDefault(st => st._vehicle._type.Id == 414);

            //Max Structures?
            if (totalCount >= c_maxStructures)
            {
                player.sendMessage(-1, "You have met or exceeded the maximum amount of structures allowed. " +
                                   "To build more, you must sell another building");

                player.inventoryModify(item, 1);
                return(false);
            }

            //Do we have a command center even?
            if (commandCenter == null && item.vehicleID != 414)
            {
                player.sendMessage(-1, "You currently do not have a active Command Center, please build one to continue..");
                player.inventoryModify(item, 1);
                return(false);
            }

            switch (item.vehicleID)
            {
            //Command Center
            case 414:
            {
                if (count > 0)
                {
                    player.sendMessage(-1, "You may only have one active Command Center.");
                    player.syncState();
                    bSuccess = false;
                }
                else if (!isAreaOpen(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //Power Station
            case 423:
            {
                if (!isAreaOpen(posX, posY, vehicle.PhysicalRadius))
                {
                    player.sendMessage(-1, "Cannot construct building, Cannot construct buildings that close to eachother.");
                    bSuccess = false;
                }
                else
                {
                    //Building!
                    bSuccess = true;
                }
            }
            break;

            //House
            case 424:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Iron Mine
            case 427:
            {
                int maxCount = commandCenter._productionLevel * 3;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Scrapyard
            case 428:
            {
                int maxCount = commandCenter._productionLevel * 3;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Villa
            case 425:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Shack
            case 415:
            {
                int maxCount = commandCenter._productionLevel * 4;
                if (count == maxCount)
                {
                    player.sendMessage(-1, "You must upgrade your command center before you may build more of this building");
                    bSuccess = false;
                }
                else
                {
                    bSuccess = canBuildInArea(player, vehicle);
                }
            }
            break;

            //Catch all
            default:
            {
                bSuccess = canBuildInArea(player, vehicle);
            }
            break;
            }
            //Give them back their kit if it failed.
            if (!bSuccess)
            {
                player.inventoryModify(item, 1);
            }

            return(bSuccess);
        }
Example #29
0
        /// <summary>
        /// Creates and adds a new vehicle to the arena
        /// </summary>
        public Vehicle newVehicle(VehInfo type, Team team, Player creator, Helpers.ObjectState state, Action <Vehicle> setupCB, Type classType)
        {       //Too many vehicles?
            if (_vehicles.Count == maxVehicles)
            {
                Log.write(TLog.Warning, "Vehicle list full.");
                return(null);
            }

            //We want to continue wrapping around the vehicleid limits
            //looking for empty spots.
            ushort vk;

            for (vk = _lastVehicleKey; vk <= UInt16.MaxValue; ++vk)
            {   //If we've reached the maximum, wrap around
                if (vk == UInt16.MaxValue)
                {
                    vk = 5001;
                    continue;
                }

                //Does such a vehicle exist?
                if (_vehicles.getObjByID(vk) != null)
                {
                    continue;
                }

                //We have a space!
                break;
            }

            //TODO: There might be some kind of strange bug regarding re-used vehicle
            //		ids, even if you attempt to dispose of them.
            _lastVehicleKey = (ushort)(vk + 1);

            //Create our vehicle class
            Vehicle veh;

            if (classType == null)
            {
                if (type.Type == VehInfo.Types.Computer)
                {
                    veh = new Computer(type as VehInfo.Computer, this);
                }
                else
                {
                    veh = new Vehicle(type, this);
                }
            }
            else
            {
                veh = Activator.CreateInstance(classType, type, this) as Vehicle;
            }

            veh._id = vk;

            veh._team    = team;
            veh._creator = creator;
            veh._oldTeam = creator != null ? creator._team : null;

            veh._tickUnoccupied = veh._tickCreation = Environment.TickCount;

            if (state != null)
            {
                veh._state.positionX = state.positionX;
                veh._state.positionY = state.positionY;
                veh._state.positionZ = state.positionZ;
                veh._state.yaw       = state.yaw;

                if (veh._type.Type == VehInfo.Types.Computer)
                {
                    veh._state.fireAngle = state.yaw; //Temporary fix for computer updates rotating north by default, perm fix would be sc_vehices.cs packet fix
                }
                if (veh._type.Type == VehInfo.Types.Dependent)
                {
                    VehInfo.Dependent dep = veh._type as VehInfo.Dependent;
                    veh._state.pitch = (byte)(dep.ChildElevationLowAngle > 0 ? dep.ChildElevationLowAngle : 0);
                }
            }

            veh.assignDefaultState();

            //Custom setup?
            if (setupCB != null)
            {
                setupCB(veh);
            }

            //This uses the new ID automatically
            _vehicles.Add(veh);

            //Notify everyone of the new vehicle
            Helpers.Object_Vehicles(Players, veh);

            //Handle dependent vehicles?
            int slot = 0;

            foreach (int vid in veh._type.ChildVehicles)
            {   //Nothing?
                slot++;

                if (vid <= 0)
                {
                    continue;
                }

                //Find the vehicle type
                VehInfo childType = _server._assets.getVehicleByID(vid);

                if (childType == null)
                {
                    Log.write(TLog.Error, "Invalid child vehicle id '{0}' for {1}.", vid, type);
                    continue;
                }

                //Create it!
                Vehicle child = newVehicle(childType, team, creator, state,
                                           delegate(Vehicle c)
                {
                    c._parent     = veh;
                    c._parentSlot = slot - 1;
                }
                                           );

                veh._childs.Add(child);

                //Notify everyone of the new vehicle
                Helpers.Object_Vehicles(Players, child);
            }

            //If it's not a spectator or dependent vehicle, let the arena pass it to the script
            if (type.Type != VehInfo.Types.Dependent && type.Type != VehInfo.Types.Spectator)
            {
                handleVehicleCreation(veh, team, creator);
            }

            return(veh);
        }
Example #30
0
 /// <summary>
 /// Creates and adds a new vehicle to the arena
 /// </summary>
 public Bot newBot(Type botType, VehInfo type, Helpers.ObjectState state, params object[] args)
 {       //Redirect
     return(newBot(botType, type, null, null, state, args));
 }