Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /*
  3.  oilRes = "OilResource";
  4.  resLab = "A0ResearchFacility";
  5.  powGen = "A0PowerGenerator";
  6.  factory = "A0LightFactory";
  7.  derrick = "A0ResourceExtractor";
  8.  cybFactory = "A0CyborgFactory";
  9.  playerHQ = "A0CommandCentre";
  10.  vtolPad = "A0VtolPad";
  11.  vtolFactory = "A0VTolFactory1";
  12.  sensorTower = "Sys-SensoTower02";
  13.  powModule = "A0PowMod1";
  14.  facModule = "A0FacMod1";
  15.  resModule = "A0ResearchModule1";
  16. */
  17. console "WARNING: This bot AI is prolly buggy."
  18. power = low: 300, medium: 900, high: 1500, ultra: 6000
  19. visibleUnits = {}
  20. units = {}
  21. enemies = {}
  22.  
  23.  
  24. /* Events */
  25. do ->
  26.  Object.defineProperty Array, "pickRandom", value: ->
  27.   return @[Math.floor Math.random! * @length]
  28.  
  29. function eventGameInit()
  30.  ;
  31. function eventStartLevel()
  32.  ;
  33. function eventLaunchTransporter()
  34.  ;
  35. function eventReinforcementsArrived()
  36.  ;
  37. function eventMissionTimeout()
  38.  ;
  39. function eventDroidIdle(droid)
  40.  ;
  41. function eventDroidBuilt(droid, structure)
  42.  ;
  43. function eventStructureBuilt(structure, droid)
  44.  ;
  45. function eventStructureReady(structure)
  46.  ;
  47. function eventAttacked(victim, attacker)
  48.  [victim, attacker] = util_callable x for x of [victim, attacker]
  49.  /* TODO: Move util_callable out of the main function somehow. */
  50.  
  51.  if victim.player == me
  52.   /*
  53.   If the bot is under attack.
  54.   TODO: figure out how to check for allies later.
  55.   */
  56.  
  57.   list_units = x of enumRange victim.x, victim.y, 20, ALLIES
  58.   /* list all nearby units which might be able to help that we can see. */
  59.  
  60.   responce_units = (x if x.player == me for x of list_units)
  61.   /* find all of the bots units nearby. */
  62.  
  63.   total_cost_me = 0; (total_cost_me += x for x of responce_units)
  64.   /* check the total cost to build all of the units. */
  65.  
  66.   total_cost_enemy = 0; (total_cost_enemy += x.cost if x isEnemy for x of list_units)
  67.   /* Find the cost of the enemies units.
  68.    FIXME: isEnemy doesn't exist, dono how to check if a player is an enemy >_>
  69.   */
  70.  ;
  71. function eventResearched(research, structure)
  72.  ;
  73. function eventDestroyed(object)
  74.  ;
  75. function eventObjectSeen(viewer, seen)
  76.  ;
  77. function eventObjectTransfer(object, from)
  78.  chat ALLIES, "Thnx."
  79.  ;
  80. function eventChat(from, to, message)
  81.  ;
  82.  
  83. function buildInitial ()
  84.  ;
  85.  
  86. function util_callable (Object_object)
  87.  a = -> arguments[0].call arguments[0], Object_object
  88.  a.__proto__ = Object_object
  89.  
  90. function listFreeTrucks ()
  91.  x if x.order != DORDER_BUILD for x of enumDroid me, DROID_CONSTRUCT
  92.  
  93. function attackEnemy (enemy)
  94.  enemy = util_callable enemy
  95.  
  96.  v_group = enumDroid enemy, undefined, me/* Droids of the enemy visible to us.*/
  97.  if v_group /* if we can see any of the enemies droids*/
  98.   orderDroidLoc(droid, order, x, y) for droid of v_group
  99.  ;
  100.  
  101. function destroy (object) # remove something
  102.  delete visibleObjects[object.id]
  103.  ;
  104.  
  105. function step ()
  106.  if playerPower me > power.high
  107.   listTrucks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement