Пример #1
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// Type = Vehicle bot uses
        /// State = direction and location of bot for spawn
        /// Arena = the arena the bot is in
        /// Team = the team the bot is on
        /// Lane = the lane the bot is assigned to [0=top,1=mid,2=bottom]
        /// Side = the side we are on, 0 = left -- 1 = right
        /// </summary>
        public RangeMinion(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_MOBA moba, Team team, int lane, int side)
        //: base(
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random(Environment.TickCount);

            _lane      = lane;
            _team      = team;
            _moba      = moba;
            _attacking = false;
            _side      = side;

            if (_side == 0)
            {
                _atWaypoint = 0;
            }
            else
            {
                _atWaypoint = _maxWaypoints;
            }

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;


            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #2
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// </summary>
        public BasicDefense(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_CTFHQ _ctfhq, Player _owner)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            //Handle movements
            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            //Our weapon to use when we are close to the enemy
            _weaponClose = new WeaponController(_state, new WeaponController.WeaponSettings());
            _weaponFar   = new WeaponController(_state, new WeaponController.WeaponSettings());

            //Equip our normal weapon
            if (type.InventoryItems[0] != 0)
            {
                _weaponFar.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            //Setup our second weapon
            if (type.InventoryItems[1] != 0)
            {
                _weaponClose.equip(AssetManager.Manager.getItemByID(type.InventoryItems[1]));
            }



            ctfhq = _ctfhq;
            owner = _owner;
        }
Пример #3
0
        public Func <InfantryVehicle, Vector3> steerDelegate; //Delegate which calculates how much steering to apply


        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic Constructor
        /// </summary>
        public SteeringController(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena)
        {
            vehicle = new InfantryVehicle(type, _state);

            //Set our position
            vehicle.Position = _state.position();
        }
Пример #4
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// Type = Vehicle bot uses
        /// State = direction and location of bot for spawn
        /// Arena = the arena the bot is in
        /// </summary>
        public RangeMinion(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_Fantasy script, int ID)
        //: base(
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random(Environment.TickCount);

            _attacking = false;

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;


            //Assign all our stats
            foreach (var p in script._spawns)
            {
                if (p.ID == ID)
                {//Found our entry, now set all the settings
                    //Targetting settings
                    targetBot      = p.atkBots;
                    targetVehicles = p.atkVeh;
                    targetPlayer   = p.atkPlayer;

                    _homeID = p.spawnID;
                    _vehID  = p.vehID;
                    //Spawn point settings
                    //p.relyOnSpawn;

                    //Distances
                    _defenseRadius    = p.defenseRadius;
                    _distanceFromHome = p.distanceFromHome;
                    _radiusToPatrol   = p.patrolRadius;
                    _lockInTime       = p.lockInTime;
                    _attackRadius     = p.attackRadius;
                    foreach (var w in p._weapons)
                    {
                        _weapons.Add(new BotWeapon(w.ID));
                        _weapons[w.ID].weaponID       = w.weaponID;
                        _weapons[w.ID].allChance      = w.allChance;
                        _weapons[w.ID].shortChance    = w.shortChance;
                        _weapons[w.ID].midChance      = w.midChance;
                        _weapons[w.ID].longChance     = w.longChance;
                        _weapons[w.ID].preferredRange = w.preferredRange;
                    }
                    _midRange  = p.shortRange + 1;
                    _longRange = p.longRange + 1;
                }
            }
            //By default set out current weapon to close range
            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #5
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public DualZombieBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_ZombieZone _zz)
            : base(type, state, arena, _zz)
        {
            bOverriddenPoll = true;
            _weaponClose    = new WeaponController(_state, new WeaponController.WeaponSettings());

            //Setup our second weapon
            if (type.InventoryItems[1] != 0)
            {
                _weaponClose.equip(AssetManager.Manager.getItemByID(type.InventoryItems[1]));
            }
        }
Пример #6
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic Constructor
        /// </summary>
        public InfantryVehicle(VehInfo.Car type, Helpers.ObjectState _state)
        {
            vehicleType = type;
            state       = _state;

            Reset();

            SpeedValues stats = vehicleType.TerrainSpeeds[0];

            MaxForce = ((stats.RollThrust * 4800) / 128) / 1000;
            MaxSpeed = stats.RollTopSpeed / 1000;
        }
Пример #7
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// </summary>
        public RoamingAttacker(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #8
0
        protected SteeringController steering;  //System for controlling the bot's steering


        public Chopper(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
        //: base(
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random(Environment.TickCount);

            steering = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #9
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public RipperV2(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena)
        {
            //bOverriddenPoll = true;
            fireDist  = 6.9f;
            farDist   = 3.4f;
            shortDist = 1.2f;
            runDist   = 0.2f;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #10
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public MedicV2(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena)
        {
            //bOverriddenPoll = true;
            farDist   = 4.4f;
            shortDist = 2.4f;
            runDist   = 1.1f;
            fireDist  = 6.6f;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[2]));
            }

            _healTargets = new Dictionary <Player, int>();
        }
Пример #11
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// </summary>
        public JungleBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_MOBA _ctfhq, Vehicle home)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _home = home;

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }
        }
Пример #12
0
        public EliteMarine(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;
            _rand       = new Random();
            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            _actionQueue = new List <Action>();
        }
Пример #13
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public CombatBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_ZombieZone _zz, Player engineer)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            zz      = _zz;
            creator = engineer;
        }
Пример #14
0
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Bot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, MovementController movement)
            : base(type, state, arena)
        {               //Initialize the event object
            eventInit(true);

            //Populate variables
            _type = type;

            _movement    = movement;
            _weapon      = new WeaponController(_state, new WeaponController.WeaponSettings());
            _activeEquip = new List <ItemInfo.UtilityItem>();

            _tickLastPoll = Environment.TickCount;

            _bBotVehicle = true;

            configureBot();
        }
Пример #15
0
        private bool _hq;                       //Tells us if HQ exists

        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// </summary>
        public Engineer(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_CTFHQ _ctfhq)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            ctfhq         = _ctfhq;
            _tickLastRet  = 0;
            _tickLastHeal = 0;
        }
Пример #16
0
        public Juggernaut(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;
            _rand       = new Random();
            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            _shotsFired = new List <Projectile>();

            _tickSpawned = Environment.TickCount;
        }
Пример #17
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// </summary>
        public Captain(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_Eol BaseScript, Player _owner)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            _baseScript = BaseScript;
            owner       = _owner;
            //figure out method to keep track of level if they died otherwise they will multiply bots - big bug
            lastCheckedLevel = 2; //They had to have gotton to level two to get a bot
        }
Пример #18
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////

        /// <summary>
        /// Generic constructor
        /// Type = Vehicle bot uses
        /// State = direction and location of bot for spawn
        /// Arena = the arena the bot is in
        /// Team = the team the bot is on
        /// Lane = the lane the bot is assigned to [0=top,1=mid,2=bottom]
        /// </summary>
        public Projectile(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_MOBA moba, Team team)
        //: base(
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random(Environment.TickCount);

            _team = team;
            _moba = moba;

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }

            _lifeTime = Environment.TickCount;
        }
Пример #19
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic Constructor
        /// </summary>
        public MovementController(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
        {
            _type    = type;
            _state   = state;
            _arena   = arena;
            bEnabled = true;

            _position  = new Vector2(state.positionX, state.positionY);
            _velocity  = new Vector2(state.velocityX, state.velocityY);
            _direction = state.yaw;

            //Copy over the relevant vehicle values
            SpeedValues t0 = type.TerrainSpeeds[0];

            _rollFriction     = t0.RollFriction;
            _rollThrust       = t0.RollThrust * 4800 / 128;
            _rollThrustStrafe = t0.StrafeThrust * 4800 / 128;
            _rollThrustBack   = t0.BackwardThrust * 4800 / 128;
            _rollRotate       = t0.RollRotate;
            _rollTopSpeed     = t0.RollTopSpeed;
        }
Пример #20
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public KingZombieBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_ZombieZone _zz)
            : base(type, state, arena, _zz)
        {
            bOverriddenPoll = true;

            weapons = new WeaponController[type.InventoryItems.Length];

            //Setup our weapons
            for (int i = 0; i < type.InventoryItems.Length; i++)
            {
                if (type.InventoryItems[i] != 0)
                {
                    weapons[i] = new WeaponController(_state, new WeaponController.WeaponSettings());
                    weapons[i].equip(AssetManager.Manager.getItemByID(type.InventoryItems[i]));
                }
                else
                {
                    weapons[i] = null;
                }
            }
        }
Пример #21
0
        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public Troop(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
            : base(type, state, arena,
                   new SteeringController(type, state, arena))
        {
            Random rnd = new Random();

            _seperation = (float)rnd.NextDouble();
            steering    = _movement as SteeringController;

            if (type.InventoryItems[0] != 0)
            {
                _weapon.equip(AssetManager.Manager.getItemByID(type.InventoryItems[0]));
            }


            settings = new WeaponController.WeaponSettings();

            settings.aimFuzziness = 8;

            _weapon.setSettings(settings);

            _shotsFired = new List <Projectile>();
            _energy     = c_maxEnergy;
        }
Пример #22
0
 /// <summary>
 /// Generic constructor
 /// </summary>
 public ScriptBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, string scriptType)
     : base(type, state, arena)
 {
     loadScripts(scriptType);
 }
Пример #23
0
        private List <Scripts.IScript> _scripts; //The scripts we're currently supporting


        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public ScriptBot(VehInfo.Car type, Arena arena, string scriptType)
            : base(type, arena)
        {
            loadScripts(scriptType);
        }
Пример #24
0
 /// <summary>
 /// Generic constructor
 /// </summary>
 public FollowBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena)
     : base(type, state, arena)
 {
 }
Пример #25
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);
        }
Пример #26
0
        public float runDist;   //The distance from the player where we run away!


        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public RangedZombieBot(VehInfo.Car type, Helpers.ObjectState state, Arena arena, Script_ZombieZone _zz)
            : base(type, state, arena, _zz)
        {
            bOverriddenPoll = true;
        }
Пример #27
0
        private int optimalDistance = 100;  //The distance we want to remain at ideally


        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public FollowBot(VehInfo.Car type, Arena arena)
            : base(type, arena)
        {
        }