Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MULTIBOT AI V1.0
- //By hobo_drew
- //This is the raw code for a multibot. It will work with any bot type, be it a spinner, walker, hammer, etc.
- //How to install:
- //-Paste the 'teamWith' script into the top of the User-Created Functions area. Adjust 'teamWith' to who your teammate is.
- //-A more basic version of getNearestEnemy is already in User-Created Functions, so you MUST replace it with this newer one.
- //How to set up:
- //'teamWith' is who the AI will NOT attack.
- //For example, if you were to set P1's teammate to "P2" and P2's teammate to "P1," then P1 and P2 would only attack P3 or P4.
- //This has to be pasted into both robots for it to work. If you set P3's teammate to P4 then it will not attack P4, but P4 will still attack P3 unless you paste the code into it as well.
- teamWith = "P1"
- getNearestEnemy = function(); pos = getMyRobot().position;nearestEnemyDistance = 1000000;nearestEnemy = {};for robot in robots;if robot.tag != myTag then;if robot.team != teamWith then;if robot.isImmobile != 1 then;if robot.isDisabled != 1 then;testDistance = getDistance(pos,robot.position);if testDistance < nearestEnemyDistance then;nearestEnemyDistance = testDistance;nearestEnemy = robot;end if;end if;end if;end if;end if;end for;return nearestEnemy;end function
Advertisement
Add Comment
Please, Sign In to add comment