/// <summary> /// Looks after the bot's functionality /// </summary> public override bool poll() { //Find the place we want to land at List <Vehicle> inTrackingRange = _arena.getVehiclesInRange(_state.positionX, _state.positionY, 10000000); foreach (Vehicle v in inTrackingRange) { if (v._type.Id == 410) { _targetLocation = v; } } //Get to landing zone if (Helpers.distanceTo(_targetLocation._state, _state) > 45) { steering.steerDelegate = steerForFollowOwner; } else { steering.freezeMovement(1000); } // if (_targetLocation._state.positionZ == _state.positionZ) return(base.poll()); }
/// <summary> /// Looks after the bot's functionality /// </summary> public override bool poll() { //Dead? Do nothing if (IsDead) { steering.steerDelegate = null; return(base.poll()); } 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); } //Do we have any projectiles to spoof damage for? if (_shotsFired.Count > 0) { Projectile proj = _shotsFired[0]; //Ballpark figure for chaingun if (now - proj.tickShotFired >= 500) { //Is it still valid? if (proj.target != null && !proj.target.IsDead) { //Simulate the damage if we're attacking a bot if (proj.target._bBotVehicle) { proj.target.applyExplosionDamage(true, _creator, proj.target._state.positionX, proj.target._state.positionY, _weapon.Projectile); } } //Erase it _shotsFired.Remove(proj); } } if (now - _tickArrivedAtLocation >= 120000 && _tickArrivedAtLocation != 0 && !_returnToBase) { _returnToBase = true; _team.sendArenaMessage("&Pavelow Pilot> We're bingo on fuel! Returning to base", 4); } if (_returnToBase) { target = _spawnMarker; bool onSite = false; //Get to landing zone if (Helpers.distanceTo(target._state, _state) > 45) { steering.steerDelegate = steerForSeekTarget; } else { steering.freezeMovement(5000); onSite = true; } //Can we drop? if (onSite) { base.destroy(true); } return(base.poll()); } if (_creator == null || _creator.IsSpectator) { destroy(true); } bool bAttacking = false; bool bBackPedal = false; //Do we need to seek a new target? if (target == null || !isValidTarget(target)) { target = getTargetBot(); } if (target != null) { bAttacking = true; //Too far? if (Helpers.distanceTo(this, target) > 420) { steering.bSkipRotate = false; steering.steerDelegate = steerForSeekTarget; } //Too short? else if (Helpers.distanceTo(this, target) < 370) { bBackPedal = true; steering.bSkipRotate = false; steering.steerDelegate = delegate(InfantryVehicle vehicle) { if (target != null) { return(vehicle.SteerForFlee(target._state.position())); } else { return(Vector3.Zero); } }; } else { steering.steerDelegate = null; //Can we shoot? if (_weapon.ableToFire() && !bBackPedal) { int aimResult = _weapon.getAimAngle(target._state); if (_weapon.isAimed(aimResult)) { //Spot on! Fire? _itemUseID = _weapon.ItemID; _weapon.shotFired(); //Damage spoofing Projectile proj = new Projectile(target, now); _shotsFired.Add(proj); } steering.bSkipAim = true; steering.angle = aimResult; } else { steering.bSkipAim = false; } } followBot(now); } //Do we have a player to follow? if (_creator.IsDead || _arena.getTerrain(_creator._state.positionX, _creator._state.positionY).safety) { return(base.poll()); } //Are we out of range of our player and not attacking anything? if (!bAttacking && Helpers.distanceTo(_creator._state, _state) > 50) { followPlayer(now); } //Handle normal functionality return(base.poll()); }
/// <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()); }