Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- oilRes = "OilResource";
- resLab = "A0ResearchFacility";
- powGen = "A0PowerGenerator";
- factory = "A0LightFactory";
- derrick = "A0ResourceExtractor";
- cybFactory = "A0CyborgFactory";
- playerHQ = "A0CommandCentre";
- vtolPad = "A0VtolPad";
- vtolFactory = "A0VTolFactory1";
- sensorTower = "Sys-SensoTower02";
- powModule = "A0PowMod1";
- facModule = "A0FacMod1";
- resModule = "A0ResearchModule1";
- */
- console "WARNING: This bot AI is prolly buggy."
- power = low: 300, medium: 900, high: 1500, ultra: 6000
- visibleUnits = {}
- units = {}
- enemies = {}
- /* Events */
- do ->
- Object.defineProperty Array, "pickRandom", value: ->
- return @[Math.floor Math.random! * @length]
- function eventGameInit()
- ;
- function eventStartLevel()
- ;
- function eventLaunchTransporter()
- ;
- function eventReinforcementsArrived()
- ;
- function eventMissionTimeout()
- ;
- function eventDroidIdle(droid)
- ;
- function eventDroidBuilt(droid, structure)
- ;
- function eventStructureBuilt(structure, droid)
- ;
- function eventStructureReady(structure)
- ;
- function eventAttacked(victim, attacker)
- [victim, attacker] = util_callable x for x of [victim, attacker]
- /* TODO: Move util_callable out of the main function somehow. */
- if victim.player == me
- /*
- If the bot is under attack.
- TODO: figure out how to check for allies later.
- */
- list_units = x of enumRange victim.x, victim.y, 20, ALLIES
- /* list all nearby units which might be able to help that we can see. */
- responce_units = (x if x.player == me for x of list_units)
- /* find all of the bots units nearby. */
- total_cost_me = 0; (total_cost_me += x for x of responce_units)
- /* check the total cost to build all of the units. */
- total_cost_enemy = 0; (total_cost_enemy += x.cost if x isEnemy for x of list_units)
- /* Find the cost of the enemies units.
- FIXME: isEnemy doesn't exist, dono how to check if a player is an enemy >_>
- */
- ;
- function eventResearched(research, structure)
- ;
- function eventDestroyed(object)
- ;
- function eventObjectSeen(viewer, seen)
- ;
- function eventObjectTransfer(object, from)
- chat ALLIES, "Thnx."
- ;
- function eventChat(from, to, message)
- ;
- function buildInitial ()
- ;
- function util_callable (Object_object)
- a = -> arguments[0].call arguments[0], Object_object
- a.__proto__ = Object_object
- function listFreeTrucks ()
- x if x.order != DORDER_BUILD for x of enumDroid me, DROID_CONSTRUCT
- function attackEnemy (enemy)
- enemy = util_callable enemy
- v_group = enumDroid enemy, undefined, me/* Droids of the enemy visible to us.*/
- if v_group /* if we can see any of the enemies droids*/
- orderDroidLoc(droid, order, x, y) for droid of v_group
- ;
- function destroy (object) # remove something
- delete visibleObjects[object.id]
- ;
- function step ()
- if playerPower me > power.high
- listTrucks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement