/// <summary> /// Checks for any special circumstances we should be handling /// </summary> protected bool checkCircumstances() { //Check for extraordinary circumstances Script_ZombieZone.TeamState state = zz.getTeamState(targetTeam); if (state != null) { if (checkForDistractions(state)) { return(true); } if (checkForCloak(state)) { return(true); } } return(false); }
/// <summary> /// Keeps the vehicle state updated, and sends an update packet if necessary /// </summary> /// <returns>A boolean indicating whether an update packet should be sent</returns> public override bool poll() { //If it isn't a turret then do nothing if (_primaryGun == null) { return(false); } //If below non-operational HP don't fire if (_state.health < _type.HitpointsRequiredToOperate) { return(false); } if (zz == null) { return(false); } //Make sure our creator is still on our team if (_creator._team == null || _creator._team != _team) { return(false); } //Get the team state Script_ZombieZone.TeamState state = zz.getTeamState(_team); //Do we need to seek a new target? if (targetZombie == null || !isValidTarget(targetZombie)) { targetZombie = getTargetZombie(state); } //Valid target? if (targetZombie == null) { return(false); } //Look at our target! _state.fireAngle = Helpers.computeLeadFireAngle(_state, targetZombie._state, _primaryProjectile.muzzleVelocity / 1000); //If not reloaded yet don't fire int now = Environment.TickCount; if (_tickShotTime + _fireDelay > now || _tickReloadTime > now) { //But maybe send an update packet? if (now - _tickLastUpdate > 300) { _tickLastUpdate = now; return(true); } return(false); } //We're firing! On a bot? if (targetZombie._bBotVehicle) { targetZombie.applyExplosionDamage(true, _creator, targetZombie._state.positionX, targetZombie._state.positionY, _primaryProjectile); } _shouldFire = true; _tickShotTime = Environment.TickCount; //Adjust ammo accordingly if (_ammoCapacity != 0 && --_ammoRemaining <= 0) { _tickReloadTime = Environment.TickCount + _reloadTime; _ammoRemaining = _ammoCapacity; } return(true); }
/// <summary> /// Looks after the bot's functionality /// </summary> public override bool poll() { //Dead? Do nothing if (IsDead) { steering.steerDelegate = null; return(base.poll()); } //Do we have a player to follow? if (creator == null || creator.IsDead || creator.IsSpectator) { kill(null); return(false); } int now = Environment.TickCount; //Get the team state Script_ZombieZone.TeamState state = zz.getTeamState(_team); //Stay close to our owner bool bClearPath = Helpers.calcBresenhemsPredicate(_arena, _state.positionX, _state.positionY, creator._state.positionX, creator._state.positionY, delegate(LvlInfo.Tile t) { return(!t.Blocked); } ); if (bClearPath) { //Persue directly! steering.steerDelegate = steerForFollowOwner; } else { //Does our path need to be updated? if (now - _tickLastPath > Script_ZombieZone.c_combatBotPathUpdateInterval) { //Update it! _tickLastPath = int.MaxValue; _arena._pathfinder.queueRequest( (short)(_state.positionX / 16), (short)(_state.positionY / 16), (short)(creator._state.positionX / 16), (short)(creator._state.positionY / 16), delegate(List <Vector3> path, int pathLength) { if (path != null) { //Is the path too long? if (pathLength > Script_ZombieZone.c_zombieMaxPath) { //Destroy ourself and let another zombie take our place _path = null; destroy(true); } else { _path = path; _pathTarget = 1; } } _tickLastPath = now; } ); } //Navigate to him if (_path == null) { //If we can't find out way to him, just mindlessly walk in his direction for now steering.steerDelegate = steerForFollowOwner; } else { steering.steerDelegate = steerAlongPath; } } //Do we need to seek a new target? if (targetZombie == null || !isValidTarget(targetZombie)) { targetZombie = getTargetZombie(state); } if (targetZombie != null) { if (bClearPath) { //Can we shoot? if (_weapon.ableToFire()) { int aimResult = _weapon.getAimAngle(targetZombie._state); if (_weapon.isAimed(aimResult) && creator.inventoryModify(2000, -_weapon.AmmoUse)) { //Spot on! Fire? _itemUseID = _weapon.ItemID; _weapon.shotFired(); //Simulate the damage if we're attacking a bot if (targetZombie._bBotVehicle) { targetZombie.applyExplosionDamage(true, creator, targetZombie._state.positionX, targetZombie._state.positionY, _weapon.Projectile); } } steering.bSkipAim = true; steering.angle = aimResult; } else { steering.bSkipAim = false; } } } //Handle normal functionality return(base.poll()); }